lundi 27 avril 2015

How organize the HTML Form with dynamic checkboxes of "params" for PHP

Variant #1 (problem get checkboxes if inactive)

<form method="POST">
<!-- values of record -->
<input name="name">
<input name="title">
<textarea name="text"></textarea>
<!-- existing params of record -->
<input name="param_value_{$id1}" value="{$value1}">
<input name="param_show_{$id1}" value="{$show1}" type="checkbox">
<input name="param_value_{$id2}" value="{$value2}">
<input name="param_show_{$id2}" value="{$show2}" type="checkbox">
<!-- new params of record -->
<input name="param_value[]" value="">
<input name="param_show[]" value="" type="checkbox">
<button>add param by JS</button>
</form>

Variant #2 (with hard JS)

<form method="POST">
<!-- values of record -->
<input name="name">
<input name="title">
<textarea name="text"></textarea>
<!-- existing params of record -->
<input name="param_value_{$id1}" value="{$value1}">
<input name="param_show_{$id1}" value="{$show1}" type="checkbox">
<input name="param_value_{$id2}" value="{$value2}">
<input name="param_show_{$id2}" value="{$show2}" type="checkbox">
<!-- new params of record -->
<input name="param_value_#?#" value="">
<input name="param_show_#?#" value="" type="checkbox">
<button>add param by JS with replace #?# by calculate index</button>
</form>

Some other best variants of HTML code for form?

P.S. Sorry for my English




Aucun commentaire:

Enregistrer un commentaire