[SOLVED] Text Input Widget to Select Widget Code
Posted: Sat Jun 19, 2004 9:27 pm
I've updated this posting since I'm not sure its 100% clear what I'm trying to do. I have code that works beautifully in a select menu to allow the user to select the qty of items (from a qty of 1 to 20). From there, the Javascript function 'UpdateQty' is called which calls the UpdateQty function to update the database and so forth.
This select menu is contained within a function called 'ShowCart' which shows the items in a users shopping cart. Anyway, I'm trying to embed the code for the 'select' menu and not having any luck.
Here is what I have thus far in my HTML code - I'd like to embed this in the PHP function 'ShowCart' so that I can have the 'select' menu appear:
Here's how I have embedded it - but it doesn't seem to show a select menu with the listed # values:
All I get is a text input box with the current qty (which by default is 1).
Can anyone help me so that I can get this working? It seems to debug fine, but the right result isn't appearing.
Thanks!
This select menu is contained within a function called 'ShowCart' which shows the items in a users shopping cart. Anyway, I'm trying to embed the code for the 'select' menu and not having any luck.
Here is what I have thus far in my HTML code - I'd like to embed this in the PHP function 'ShowCart' so that I can have the 'select' menu appear:
Code: Select all
<td width="15%" height="25"><select name="<?php echo $rowї"piecenum"]; ?>" onChange="UpdateQty(this)">
<?php
for($i = 1; $i <= 20; $i++)
{
echo "<option ";
if($rowї"qty"] == $i)
{
echo " SELECTED ";
}
echo ">" . $i . "</option>";
}
?>
</select>
</td>Code: Select all
<?php
//Show quantity of this item in a text input widget. The user can alter the quantity and update it
echo "\n<tr>";
echo "\n\t<td>" .
"<select name=",$row["piecenum"]," onChange=UpdateQty(this)>";
for($i = 1; $i <= 20; $i++)
{
echo "<option ";
if($row["qty"] == $i)
{
echo " SELECTED ";
}
echo ">" . $i . "</option>";
}
"</select></td>";
?>Can anyone help me so that I can get this working? It seems to debug fine, but the right result isn't appearing.
Thanks!