Hi
I'm pretty new to VBScript and I'd appreciate some help with the following issue. I want to create an event handler for the onchange event in a select tag. I need the selectedIndex and option value when a listbox selection is changed. The list box is loaded from an access db and this seems to be working fine. I created a simple script to provide an alert containing the information of interest when the selection changes. The alert works when coded in line in the select tag. The alert does not work when i call an event handler.
Here are the code fragments:
This works:
This works too:
.../header, body, and form tags go here
This does not work:
...
Why is the alert in the 2nd event handler not working?
I have tried passing a parameter in the call as in StudyId(this), and changed the alert msgtext to use the parameter, I've also tried to formally define the parameters in the alert msgtext as in form1.StudyId.selectedIndex. Neither of these options worked for me.
Any help would be greatly appreciated.
Thanks.
I'm pretty new to VBScript and I'd appreciate some help with the following issue. I want to create an event handler for the onchange event in a select tag. I need the selectedIndex and option value when a listbox selection is changed. The list box is loaded from an access db and this seems to be working fine. I created a simple script to provide an alert containing the information of interest when the selection changes. The alert works when coded in line in the select tag. The alert does not work when i call an event handler.
Here are the code fragments:
This works:
Code:
<select name="StudyId" size="1" id="StudyId" onchange="alert('Index: ' + this.selectedIndex + '\nValue: ' + this.options(this.selectedIndex).value)">
This works too:
Code:
<Script language=VBScript>
Sub StudyId_onchange()
alert("Hello from selected")
End Sub
</Script>
.../header, body, and form tags go here
Code:
<select name="StudyId" size="1" id="StudyId" onchange="StudyId">
This does not work:
Code:
<Script language=VBScript>
Sub StudyId_onchange()
alert("Index: " + this.selectedIndex + "\nValue: " + this.options(this.selectedIndex).value)
End Sub
</Script>
Code:
<select name="StudyId" size="1" id="StudyId" onchange="StudyId">
Why is the alert in the 2nd event handler not working?
I have tried passing a parameter in the call as in StudyId(this), and changed the alert msgtext to use the parameter, I've also tried to formally define the parameters in the alert msgtext as in form1.StudyId.selectedIndex. Neither of these options worked for me.
Any help would be greatly appreciated.
Thanks.