tarad
07-24-2008, 04:57 PM
Hi there!
All right, here's the situation: we have a form, and a couple of the drop down menus refresh the page (and actually submit the form) when they've been changed. If any of the other drop downs or fields have been changed, the changes disappear (as they should) when the page refreshes.
I'm trying to get one of the drop downs selected item to stick around when the page refreshes.
Here's a chunk of the code:
while ($row = $db->fetch_array($result)) {
echo "<option value=\"$row[0]\" ";
if ($_POST[supporter_id] == $row[0])
{
echo "selected";
}
else if ($info['supporter_id'] == $row[0])
{
echo "selected";
}
echo "> $row[1] </option>";
}
So... It would make sense that the value coming from $_POST is the most recently selected value. So, I'm trying that one first. Then, if its not, then we'll revert to the original one, coming in from the $info array.
A weird thing happens when I view the source after the page has been refreshed/submitted - "selected" is echoed both after the newly selected item from the $_POST variable, and after the original item. I can't figure out why.
Shouldn't the page and form be completely reloading on the refresh, ie. clearing the "selected" off the original item? If something's coming in off the $_POST, then only that part of the if should be executing, right?
Any thoughts would be greatly appreciated. If I'm not making sense, let me know and I'll try to clarify.
Thanks,
Tara
All right, here's the situation: we have a form, and a couple of the drop down menus refresh the page (and actually submit the form) when they've been changed. If any of the other drop downs or fields have been changed, the changes disappear (as they should) when the page refreshes.
I'm trying to get one of the drop downs selected item to stick around when the page refreshes.
Here's a chunk of the code:
while ($row = $db->fetch_array($result)) {
echo "<option value=\"$row[0]\" ";
if ($_POST[supporter_id] == $row[0])
{
echo "selected";
}
else if ($info['supporter_id'] == $row[0])
{
echo "selected";
}
echo "> $row[1] </option>";
}
So... It would make sense that the value coming from $_POST is the most recently selected value. So, I'm trying that one first. Then, if its not, then we'll revert to the original one, coming in from the $info array.
A weird thing happens when I view the source after the page has been refreshed/submitted - "selected" is echoed both after the newly selected item from the $_POST variable, and after the original item. I can't figure out why.
Shouldn't the page and form be completely reloading on the refresh, ie. clearing the "selected" off the original item? If something's coming in off the $_POST, then only that part of the if should be executing, right?
Any thoughts would be greatly appreciated. If I'm not making sense, let me know and I'll try to clarify.
Thanks,
Tara