我的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();