Thread View: comp.lang.javascript
2 messages
2 total messages
Started by Koen Appeltans
Tue, 11 Dec 2001 11:00
Scope problem of <select> variable
Author: Koen Appeltans
Date: Tue, 11 Dec 2001 11:00
Date: Tue, 11 Dec 2001 11:00
21 lines
1625 bytes
1625 bytes
Hello, I'm having a problem with the following HTML/javascript code: <SELECT onchange="VPEchanged" id=verpleeg name=verpleeg size=1> <OPTION value = 0>Geen</OPTION> <OPTION value = 1>Test</OPTION> </SELECT> <SCRIPT language="javascript"> verpleeg.options[1].selected = true; </SCRIPT> he gives an error in the script : verpleeg is not defined Why can't I use that variable anymore ?? How can I solve this problem ?? It's probably a very basic question, but I've been searching now for a while allready, so I'd really appreciate some help! Tnx in advance, Koen Appeltans
Re: Scope problem of <select> variable
Author: Jim Ley
Date: Tue, 11 Dec 2001 11:22
Date: Tue, 11 Dec 2001 11:22
28 lines
1997 bytes
1997 bytes
On 11 Dec 2001 03:00:24 -0800, koenappeltans@hotmail.com (Koen Appeltans) wrote: >Hello, > >I'm having a problem with the following HTML/javascript code: > > <SELECT onchange="VPEchanged" id=verpleeg name=verpleeg size=1> > <OPTION value = 0>Geen</OPTION> ><OPTION value = 1>Test</OPTION> > </SELECT> > <SCRIPT language="javascript"> > verpleeg.options[1].selected = true; ></SCRIPT> > >he gives an error in the script : verpleeg is not defined >Why can't I use that variable anymore ?? You never been able to, well not in any definitions, it's error correction, the select is part of a form, so you use the forms array document.forms['formname'].elements['verpleeg'] is what you should be using rather than just verpleeg Jim. -- comp.lang.javascript FAQ http://jibbering.com/faq/
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads