我有大量的输入字段。如何将值传递到数组中,以便将数组从一页传递到另一页?例:
<input type="text" value=<?php $arry = "compName" ?> placeholder="Company Name" />
这合法吗?如何正确执行此操作?
编辑:
在我的页面中,我有“添加”和“删除”按钮,它们将添加/删除更多输入字段。我还在底部有一个“预览”按钮。用户将在点击预览之前添加/删除。预览将收集所有输入并调用下一页。因此,场的数量是未知的。
这是我的代码/标记的样子:
<div class="panel" style="width: 98%; margin:0 auto">
<div class="row">
<div class="large-6 columns">
Advertiser Info: <hr>
<input type="text" value="compName" placeholder="Company Name" />
<input type="text" value= "adEmail" placeholder="Email" />
<input type="text" value="adContName" placeholder="Contact Name" />
<input type="text" value="adPhone" placeholder="Phone # (NO DASHES)" />
<input type="text" value="adStreet" placeholder="Street Address" />
<input type="text" value="adCity" placeholder="City" />
<input type="text" value="adState" placeholder="State/Provice" />
<input type="text" value="adZip" placeholder="Zip/Postal Code" />
<input type="text" value="adCountry" placeholder="Country" />
</div>
<div class="large-6 columns">
Billing Info: <hr>
<input type="text" value="bEmail" placeholder="Email" />
<input type="text" value="bContName" placeholder="Contact Name" />
<input type="text" value="bPhone" placeholder="Phone # (NO DASHES)" />
<input type="text" value="bStreet" placeholder="Street Address" />
<input type="text" value="bCity" placeholder="City" />
<input type="text" value="bState" placeholder="State/Provice" />
<input type="text" value="bZip" placeholder="Zip/Postal Code" />
<input type="text" value="bCountry" placeholder="Country" />
</div>
</div>
</div>
因此,当用户点击添加时,将复制以上代码的精确副本。
话虽如此,我希望能够使用PHP数组传递html值。如何设置输入,以便可以执行此操作?
您可以进行一些调整,例如:
使用输入类型元素作为数组元素。
以便:
<input type="text" name="elem[name]" value="<?php echo $YOUR_VALUE;?>"
<input type="text" name="elem[class]" value="<?php echo $YOUR_VALUE;?>"
<input type="text" name="elem[marks]" value="<?php echo $YOUR_VALUE;?>"
这样您发布的变量应该更少。
在这种情况下,您将只发布一个变量,而不是三个。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句