Click to See Complete Forum and Search --> : document.form.select.value propertie in IExplorer and Netscape
dvera
01-29-2003, 12:44 PM
Hello,
When I use the propertie document.form.select.value in Netscape I don't have any problem. Otherwise when i use this in IExplorer (V. 5.0) I can't get the selected value.
What can i do to solve this problem?
Thankyou
khalidali63
01-29-2003, 12:51 PM
The correct syntax to get value for an option in a listbox is as follows.
get the selected Items index.
var index = document.formName.listBox.selectedIndex;
get selected index's value
var val = document.formName.listBox[index].value;
cheers.
khalid
dvera
01-29-2003, 01:56 PM
Now, when I use the instructions you gave me, It still doesn't work in Netscape and Explorer. Here you have an example that I've done.
function redirection()
{
var index = document.form1.user.selectedIndex;
var val = document.form1.user[index].value;
alert(val); //*** it doesn't show any option
document.location="menu_editar_cliente.jsp?usr=" + document.form1.user[index].value;
}
<form name="form1" action="" method="get" onsubmit="javascript:checkMail(this)">
<select name='user' onchange="javascript:redirection()">
...
</select>
</form>
Thanks again
khalidali63
01-29-2003, 03:44 PM
get rid of javascript: in onsubmit and onchange event calls.
Your html code should look like this
<form name="form1" action="" method="get" onsubmit="checkMail(this)">
<select name='user' onchange="redirection()">
unless there is something else in your html code or JavaScript that is not seen here,it will work.
cheers
Khalid
gil davis
01-30-2003, 06:19 AM
Originally posted by dvera
var val = document.form1.user[index].value;Should be:
var val = document.form1.user.options[index].value;
document.location="menu_editar_cliente.jsp?usr=" + document.form1.user[index].value;Should be:
window.location.href="menu_editar_cliente.jsp?usr=" + document.form1.user.options[index].value;