Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 DOMdocument 创建表单。要在字段集中添加更多输入框,我使用这个:
$fieldset->appendChild ( $textinput->cloneNode());
我想学习如何更改克隆输入框的id和名称。例如,第一个输入框是 id = "box", name="box-input",那么在克隆中,我希望它是 id="box-2", name = "box-input-2"。这可以做到吗?
首先克隆它,更改属性并附加它:
$clone = $textinput->cloneNode(); $clone->setAttribute('id', '...'); $clone->setAttribute('name', '...'); $fieldset->appendChild($clone);