forms - Combine Checbox wtih Text Field in PHP -


i'm try combine checkbox values text field 1 variable, when echo out shows correct fields values.

i want combine post of checkbox of quantity text field, because there several items i'm using forloop can't seem combine both values 1 creates new table row item name on left , quantity on right.

<tr>    <td>       <input type="checkbox" name="check[]" value="<?php echo get_post_meta($post->id, '_stitle', true); ?>" />    </td>     <td>       <input id="quantity" name="check[quantity]" type="text" maxlength="3" /><br />    </td> 

  $data = $_post['check'];         foreach ($data $value) {         $item .= '<tr style="background: #eee;">                 <td>item: </td>                 <td>'.$value.'</td>             </tr>';         } 

you should change:

<input id="quantity" name="check[quantity]" type="text" maxlength="3" /><br /> 

to:

<input id="quantity" name="check[quantity][]" type="text" maxlength="3" /><br /> 

you scalar checkbox not textfield.

also, simpler relate 2 fields for, array key's same between each checkbox , input field.

example:

for($i=0;$i<=sizeof($_post['check'])-2;$i++){     $item .= '<tr style="background: #eee;">             <td>item: '.$_post['check'][$i].'</td>             <td>'.$_post['check']['quantity'][$i].'</td>         </tr>'; } 

also, note -2 sizeof $_post. must subtract both quantity key , offset set ending point equal since counting 0.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -