Piotto
11-14-2009, 07:20 PM
Hi everybody!
I have a form in a catalogue page that is populated by a flat DB and has checkboxes.
In order to send data from the catalogue page to another php page i am using the checkboxes value, that (in my code... :rolleyes:) contains the different values for product name, unit price and quantity separated by me with a "|" that come straight from the db.
After submit, in the next page i count and echo the value of the checkbox of each product selected from the catalogue and i sort out (splitted by "|") the different fields.
Now, I would like to be able to let the user changes the quantity field in the first page and send the new value along with the actual form, inside the checkbox value, to the other page, doing a calculation before sending {like subtotal of each product (price * the new inputted quantity)}. The initial value stored in the db is 1.
After connecting to the db I have this code in the first page:
[CODE]
... connect to db and get data...
...$itemid
...$itemname
...$itemphoto
...$itemdescr
...$itemprice
...$itemquantity etc ...
$subtotal = $itemprice * $itemquantity;
echo"
<tr><td align='center' height='25' valign='top'>
<input readonly type='text' STYLE='text-align:center;border=0;' name='itemname' size='25' value='$itemname'>
<input type='text' STYLE=text-align:center;background:#C0FFC0; name='itemquantity' size='2' value='$itemquantity'></td>
<td align='center' height='25' valign='top'>
<img src='$itemphoto' name='itemphoto' border='1'></td>
<td align='center' width='200' valign='top'>
<p align='justify' style='font-family:verdana; font-size:11px;'>$itemdescr</p></td>
<td align='center' height='25' valign='top'>
<input readonly type='text' STYLE='text-align:center;border=0;' name='itemprice' size='12' value='$itemprice Mts.'></td>
<td align='center' height='25' valign='top'>
<input type='checkbox' name='pickitem[]' value='$itemname|$itemprice|$itemquantity|$subtotal<br>'></td>
</tr><tr><td height='25' align='center' colspan='6'><hr size='3' color='#000080'></td></tr></center>
";
}
echo "</table><br><input type='submit' value='Calcular Cotação' name='calcular'></form></body></html>";
Now, no matter what i write in the quantity textbox, the result on the other page is still 1.
How can i enable the new value, inputted by the user to go along with the checkbox value and replace the value 1 from the db???
Anyway, there is another way to send the values of the selected products in another page without putting variables into the value field of the checkboxes?
thks (tired and with eyes burning.....) :confused:
I have a form in a catalogue page that is populated by a flat DB and has checkboxes.
In order to send data from the catalogue page to another php page i am using the checkboxes value, that (in my code... :rolleyes:) contains the different values for product name, unit price and quantity separated by me with a "|" that come straight from the db.
After submit, in the next page i count and echo the value of the checkbox of each product selected from the catalogue and i sort out (splitted by "|") the different fields.
Now, I would like to be able to let the user changes the quantity field in the first page and send the new value along with the actual form, inside the checkbox value, to the other page, doing a calculation before sending {like subtotal of each product (price * the new inputted quantity)}. The initial value stored in the db is 1.
After connecting to the db I have this code in the first page:
[CODE]
... connect to db and get data...
...$itemid
...$itemname
...$itemphoto
...$itemdescr
...$itemprice
...$itemquantity etc ...
$subtotal = $itemprice * $itemquantity;
echo"
<tr><td align='center' height='25' valign='top'>
<input readonly type='text' STYLE='text-align:center;border=0;' name='itemname' size='25' value='$itemname'>
<input type='text' STYLE=text-align:center;background:#C0FFC0; name='itemquantity' size='2' value='$itemquantity'></td>
<td align='center' height='25' valign='top'>
<img src='$itemphoto' name='itemphoto' border='1'></td>
<td align='center' width='200' valign='top'>
<p align='justify' style='font-family:verdana; font-size:11px;'>$itemdescr</p></td>
<td align='center' height='25' valign='top'>
<input readonly type='text' STYLE='text-align:center;border=0;' name='itemprice' size='12' value='$itemprice Mts.'></td>
<td align='center' height='25' valign='top'>
<input type='checkbox' name='pickitem[]' value='$itemname|$itemprice|$itemquantity|$subtotal<br>'></td>
</tr><tr><td height='25' align='center' colspan='6'><hr size='3' color='#000080'></td></tr></center>
";
}
echo "</table><br><input type='submit' value='Calcular Cotação' name='calcular'></form></body></html>";
Now, no matter what i write in the quantity textbox, the result on the other page is still 1.
How can i enable the new value, inputted by the user to go along with the checkbox value and replace the value 1 from the db???
Anyway, there is another way to send the values of the selected products in another page without putting variables into the value field of the checkboxes?
thks (tired and with eyes burning.....) :confused: