1

I have one strange question, and couldn't find answer or any clue for this, no matter how lame it seems... so need some help...

with PHP code I'm generating HTML form:

$html = '
<form name="manual" action="manual.php" method="post">
<table>';
$sql = "SELECT * from table;";
$result = pg_query($sql);
while ($row = pg_fetch_assoc($result))
{        
    $html .= '
    <tr>
        <td ><input type="text" id="cid'.$row['trans_id'].'" name="cids[]" value="'.$row['case_id'].'"/></td>
        <td ><input type="text" id="ccid'.$row['trans_id'].'" name="ccids[]" value="'.$row['client_case_id'].'"/></td>
        <td ><input type="checkbox" id="trnum'.$row['trans_id'].'" name="trs[]" value="'.$row['trans_id'].'"/></td>
    </tr>';
}
$html .= '</table>
<input type="button" value="Submit" />';

which reproduces html form with multiple rows and some data with it:

...
<tr>
<td ><input type="text" id="cidrow1" name="cids[]" value="1" /></td>
<td ><input type="text" id="ccidrow1" name="ccids[]" value="4"></td>
<td ><input type="checkbox" id="trnumrow1" name="trs[]" value="row1"/></td>
</tr>
<tr>
<td ><input type="text" id="cidrow2" name="cids[]" value="2" /></td>
<td ><input type="text" id="ccidrow2" name="ccids[]" value="43"></td>
<td ><input type="checkbox" id="trnumrow2" name="trs[]" value="row2"/></td>
</tr>
<tr>
<td ><input type="text" id="cidrow3" name="cids[]" value="3" /></td>
<td ><input type="text" id="ccidrow3" name="ccids[]" value="32"></td>
<td ><input type="checkbox" id="trnumrow3" name="trs[]" value="row3"/></td>
</tr>
<tr>
<td ><input type="text" id="cidrow4" name="cids[]" value="4" /></td>
<td ><input type="text" id="ccidrow4" name="ccids[]" value="56"></td>
<td ><input type="checkbox" id="trnumrow4" name="trs[]" value="row4"/></td>
</tr>
...

I need user to make changes to two input text fields and once checked and verified to select check-box in same row where those two fields are located.

Once the user submits the form i have to check if all input fields belonging to selected check-boxes are filled (java-script should to trick here before form is sent back to server) and send back to server values from all selected check-boxes and corresponded input fields.

For example if in html form row 1, 3, 4 check-boxes are selected i need to get data from input fields of cid[], ccids[] and check-boxes for those rows.

Melkior
  • 13
  • 6
  • @fermionoid: ID's in original code are unique. I must have overlooked it when I typed here. _Edited original post._ – Melkior Jan 03 '13 at 20:36
  • @melkior oh well, I thought that could be an issue, sorry man, don't know much else :( – user115422 Jan 03 '13 at 21:29
  • Actually i have find answer: [How to submit multiple array checkbox with html forms][1]! This feed shows how to pinpoint to selected check-boxes. Regards, Melkior [1]: http://stackoverflow.com/questions/11820608/how-to-submit-multiple-array-checkbox-with-html-forms – Melkior Jan 03 '13 at 21:29

2 Answers2

1

The problem is your IDs are not unique. Please make sure always your ids are unique.

LPD
  • 2,833
  • 2
  • 29
  • 48
0

Actually i have find answer: How to submit multiple array checkbox with html forms!

This feed shows how to pinpoint to selected check-boxes.

Regards, Melkior

Community
  • 1
  • 1
Melkior
  • 13
  • 6