can't get value from select box! Help!

S

Sharon

Hello,
Why is it that I do get the value from my text box but I cannot get
the value from my select box which is located in the same form? This
is the code I use:

var text1 = frmMain.filter1txt.value;
var sel1 = frmMain.filter1sct.options[frmMain.filter1sct.selectedIndex].value;


<form name="frmMain">
<table align="center" id="Table1" width="600px"">
<tr>
<td>
<SELECT NAME="Filter1sct">
<OPTION VALUE="fclient">client</OPTION>
<OPTION VALUE="fid">sleutelveld</OPTION>
<OPTION VALUE="fusername">username</OPTION>
<OPTION VALUE="fname">naam</OPTION>
<OPTION VALUE="fcity">woonplaats</OPTION>
<OPTION VALUE="fdebno">debiteurnr</OPTION>
</SELECT>
</td>
<td>
<input type="text" name="filter1txt" value="All"><br>
</td>
</tr>
</table>
</form>

Hope someone can help me, thanks a lot! Sharon
 
S

Stephen Chalmers

Sharon said:
Hello,
Why is it that I do get the value from my text box but I cannot get
the value from my select box which is located in the same form? This
is the code I use:

var text1 = frmMain.filter1txt.value;
var sel1 = frmMain.filter1sct.options[frmMain.filter1sct.selectedIndex].value;


<form name="frmMain">
<table align="center" id="Table1" width="600px"">
<tr>
<td>
<SELECT NAME="Filter1sct">
<OPTION VALUE="fclient">client</OPTION>
<OPTION VALUE="fid">sleutelveld</OPTION>
<OPTION VALUE="fusername">username</OPTION>
<OPTION VALUE="fname">naam</OPTION>
<OPTION VALUE="fcity">woonplaats</OPTION>
<OPTION VALUE="fdebno">debiteurnr</OPTION>
</SELECT>
</td>
<td>
<input type="text" name="filter1txt" value="All"><br>
</td>
</tr>
</table>
</form>

Hope someone can help me, thanks a lot! Sharon


var sel1 =
frmMain.filter1sct.options[frmMain.filter1sct.selectedIndex].value;

<SELECT NAME="Filter1sct">

You should be getting the error: "frmMain.filter1sct.options" is not an
object

It's a classic case of incorrect case.
 
S

Sharon Steringa

Well, actually, I found another error and now it's working properly...
The thing was that first I let users select the column they want to
filter from the select box and then fill in the value on which they want
it to be filtered. So the focus shifts from the select box to the text
box. When I just use
frmMain.filter1sct.value;
I actually get the right result. Thanks anyway!!! Sharon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,781
Messages
2,569,619
Members
45,314
Latest member
HugoKeogh

Latest Threads

Top