Jump to content

[SOLVED] Need serious help with this - <option selected value ... Getting wrong value


Beauford

Recommended Posts

I have been working for over 6 hours on this one stupid thing and for the life of me I just can't figure it out.

 

I have a simple Select statment and an <option selected, which gets its value from a mysql db. That works and the value is there, but when I click on submit it always sends the value from the first option in the list below the option selected.

 

<form action='staff_items.php?action=edititemform' method='post'>
<select name='item' type='dropdown'>";
<option selected value='".$itm['cityid']."'>".$itm['cityname']."</option>
while($itm=$db->fetch_row($i)) {
echo "<option value='{$itm['itmid']}'>{$itm['itmname']}</option>";
}
echo "</select><br>

 

 

I have echoed the value for $itm['cityid']  and it is correct, but when I submit the form it takes the value from the first option in the list, which happens to have a value of 0 - which is correct - but why is the selected value not being sent and that one is???????

 

This is just nuts.

 

Thanks for any input as I have no idea how to solve this.

 

 

Link to comment
https://forums.phpfreaks.com/topic/131462-solved-need-serious-help-with-this/
Share on other sites

Resolved. I have no idea why, but for some reason the name I used for the select statement was causing the problem. Soon as I changed it, it worked perfectly.

 

I did a seach of the entire script and could not find any other instance of this name, so not sure what the problem was with it.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.