mardi 14 mars 2017

PHP or JS GET form: How to add a field if checkbox is checked

I have basic html form with several checkbox fields. I want to add another field if a checkbox is checked so the added field is passed via url. My code so far, but it is not working:

<form action="/s/mypage/" method="GET">
<input name="id1" type="checkbox" value="ime" checked/>Input 1
<input name="id11" type="checkbox" value="deinost" />Input 11
<input name="id2" type="checkbox" value="adres" />Input 2
<input name="id3" type="checkbox" value="kapital" />Input 3
<input name="id4" type="checkbox" value="upravitel" />Input 4
<input name="id5" type="checkbox" value="sobstvenik" />Input 5
<input name="id6" type="checkbox" value="drugo" />Input 6
<input name="" type="submit" value="go ahead" />

<?php
if (isset($_GET["id[1]"])) {
echo '<input type="hidden" name="do" value="12345" />';
}
?>
</form>

How can i do that? It is not neccessary to be with php, javascript will be fine.




Aucun commentaire:

Enregistrer un commentaire