dongyun8075 2013-08-19 19:09 采纳率: 100%
浏览 18

一个表单,在新的DomDocument上有许多提交按钮和PHP

My DomDocument will only put down 1 submit button. I need all buttons to be submits, but only the first one does and the rest are turned into textareas, even though I specify "submit".

I know i can do this with HTML, but DomDocuments only prints out 1 submit.

How can I have more then 1 submit button:

Code:

$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();
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?