[Javascript] value of select

Flavio Gomes flavio at economisa.com.br
Mon Apr 25 08:47:03 CDT 2005


I don't know why it doesn't worked or if should it work, but you can try 
removing the 'options' statement

var myComboBox = document.orders.orders_status_id; //this is just for 
simplifying
var orders_status_id = myComboBox[myComboBox.selectedIndex].value;

   // myComboBox.options[0] is the same as myComboBox[0]

Second: have you realised that in the "OPTION" that says '1' it's value 
is empty and in the "OPTION" that says '2' it's value is '1', right?

Hope to Help,

-- 
Flavio Gomes
flavio at economisa.com.br



Michael Borchers wrote:

>Well, you didn't have the opening <script> tag or a submit button. But
>it worked once I added those.
>
><form action="..." method="post" name="orders" onSubmit="return
>orders_submit()">
><select name="orders_status_id">
> <option value="">1</option>
> <option value="1">2</option>
></select>
>
><input type="submit" id="btnSubmit" name="btnSubmit" value="Submit Form" />
></form>
>
>
><script type="text/javascript">
>function orders_submit()
>{
>       var orders_status_id      =
>document.orders.orders_status_id.options[document.orders.orders_status_id.selectedIndex].value;
>
>       if (orders_status_id == "1")
>       {
>               alert('test');
>       }
>}
></script>
>
><
>
>sorry, my mistake when i copied the code,
>of course i had the missing tags in my original script too:)
>but still it won't work:(
>
>it says:
>document.orders.orders_status_id.options is empty:(
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript
>  
>



More information about the Javascript mailing list