Osny Netto
Osny Netto

Reputation: 572

Many fields in HTML form

I have a form with about 150 fields, however the user can add more fields, reaching about 300 fields. I'd like to know if exist a good way to put names and IDs to my fields, or i have to give each one a diferent name and ID. It's a hard job.

Upvotes: 1

Views: 1253

Answers (2)

rauschen
rauschen

Reputation: 3996

html with only one name for input

 <form action="checkbox.php">
<input type="checkbox" name="data[]" value="1">1<br>
<input type="checkbox" name="data[]" value="2">2<br>
<input type="checkbox" name="data[]" value="3">3<br>
<input type="checkbox" name="data[]" value="4">4<br>
<input type="checkbox" name="data[]" value="5">5<br>
<input type="submit">
</form>

checkbox.php

$data = $_GET["data"]; //$data is an array with checked option

it works also for type text

<input type="text" name="text_data[1]"><br>
<input type="text" name="text_data[2]"><br>
<input type="text" name="text_data[3]"><br>

Upvotes: 2

Milan Mendpara
Milan Mendpara

Reputation: 3131

if i understand in right, then you can use same name,id for group of same types of control (group of textbox,checkbox,etc...) and then access as array from javascript or code behind ..

Upvotes: 2

Related Questions