string value in select tag not working as desired with strings
| From: | Fahim Mohammad | Date: | Thu, 19 May 2011 21:11:26 +0000 |
| Subject: | string value in select tag not working as desired with strings | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-47793@lists.php.net to get a copy of this message | ||
Hi
I have the following code:
When the option value is integer, the select button is working perfectly
selecting the option. In case when the value is string, the post value does
reflect the selected item in the selection box but does not select it. I am
totally confused what is wrong with my code.
<script language="JavaScript">
function autoSubmit()
{
var formObject = document.forms['theForm'];
formObject.submit();
}
</script>
<select name="organism" onChange="autoSubmit();">
<option value="null">Select Organism</option>
<option value= "9606" <?php if($organism == 9606) echo "
selected"; ?>>human</option>
<option value= "10090" <?php if($organism == 10090) echo "
selected";
?>>mouse</option>
<option value= "10116" <?php if($organism == 10116) echo "
selected";
?>>rat</option>
</select>
the above code does select the clicked entry in selection box but the
following code does not select the clicke item and always shows organism.
<select name="organism" onChange="autoSubmit();">
<option value="null">Select Organism</option>
<option value= 'human' <?php if(strcmp($organism, 'human') == 0)
echo "
selected"; ?>>human</option>
<option value= 'mouse' <?php if(strcmp($organism, 'mouse') == 0)
echo "
selected"; ?>>mouse</option>
<option value= 'rat' <?php if(strcmp($organism,'rat') == 0) echo
"
selected"; ?>>rat</option>
</select>
Any help???
thanks
Fahim