Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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.

share|improve this question
2  
Ids MUST be unique –  j08691 Jan 3 '13 at 17:01
    
@fermionoid: ID's in original code are unique. I must have overlooked it when I typed here. Edited original post. –  Melkior Jan 3 '13 at 20:36
    
@melkior oh well, I thought that could be an issue, sorry man, don't know much else :( –  user115422 Jan 3 '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]: stackoverflow.com/questions/11820608/… –  Melkior Jan 3 '13 at 21:29
add comment

2 Answers

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

share|improve this answer
add comment
up vote 0 down vote accepted

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.