Hi, I’m new with Javascript and I have the following problem,
I use the Select() function to retrive and display in alert box
the index and the text value of a drop down element option.
My problem is that the t_index and the t_value variables seem to both store the index value, even though I want to store the text value for the second one.
Could someone provide me with some idea of what I am doing wrong..?
Many thanks in advance……
//************************************************
function Select() {
alert(“Passed_1. Entered the function…”);
var t_index = document.activeElement.value;
alert(“Passed_2. Value of t_index is: ” + t_index);
var listBox = document.getElementById(“main”).Make;
var t_value = (listBox.options[t_index].value);
alert(“Passed_3. The value of val is: ” + t_value);
}
// End –>
</script>
</HEAD>
<!– STEP TWO: Copy this code into the BODY of your HTML document –>
<BODY>
<center>
<FORM NAME=”main”>
<SELECT NAME=”Make” onChange=”Select()”>
<OPTION VALUE=”-1″>Select a Test
<OPTION VALUE=1>test_1
<OPTION VALUE=2>test_2
<OPTION VALUE=3>test_3
<OPTION VALUE=4>test_4
</SELECT>
<BR>
<SELECT NAME=”Result” >
</SELECT>
</FORM>
</center>