Jump to content

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


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.

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.