0

我的 DomDocument 只会放下 1 个提交按钮。我需要提交所有按钮,但只有第一个按钮会提交,其余按钮会变成 textareas,即使我指定了“提交”。

我知道我可以用 HTML 做到这一点,但 DomDocuments 只打印出 1 个提交。

我怎样才能有超过 1 个提交按钮:

代码:

$tSForm = new DOMDocument;
$tSFRoot = $tSForm->createElement('Form', '');
$tSFId =  $tSForm->createAttribute('ID');
$tSFId->value = 'tSFORM';
$tSFRoot->appendChild($tSFId);
$tSFAction = $tSForm->createAttribute('Action');
$tSFAction->value = $_SERVER['PHP_SELF'];
$tSFRoot->appendChild($tSFAction);
$tSFMethod = $tSForm->createAttribute('Method');
$tSFMethod->value = 'POST';
$tSFRoot->appendChild($tSFMethod);

/// Create Button 1    
$tSFB1 = $tSForm->createElement('Input','');
$tSFB1Type = $tSForm->createAttribute('type');
$tSFB1Type->value = 'submit';
$tSFB1->appendChild($tSFB1Type);
$tSFB1Name = $tSForm->createAttribute('name');
$tSFB1Name->value = 'print';
$tSFB1->appendChild($tSFB1Name);
$tSFB1Name = $tSForm->createAttribute('value');
$tSFB1Name->value = 'PRINT';
$tSFB1->appendChild($tSFB1Name);
$tSFRoot->appendChild($tSFB1);
/// Create Button 2
$tSFB2 = $tSForm->createElement('Input','');
$tSFB2Type = $tSForm->createAttribute('type');
$tSFId->value = 'submit';
$tSFB2->appendChild($tSFB2Type);
$tSFB2Name = $tSForm->createAttribute('name');
$tSFB2Name->value = 'newTS';
$tSFB2->appendChild($tSFB2Name);
$tSFB2Name = $tSForm->createAttribute('value');
$tSFB2Name->value = 'New Time Sheet';
$tSFB2->appendChild($tSFB2Name);
$tSFRoot->appendChild($tSFB2);
/// Create Button3

$tSForm->appendChild($tSFRoot);
echo $tSForm->saveHTML();
4

0 回答 0