Hi,
I'm kind of new to JavaScript - more of a VB programmer. So this may be a simple fix; I don't know.
I've got a form (pharmreg) that has two select boxes (memberof and conferenceoption). The options in conferenceoption depend on the value selected in memberof, because depending on what you are a member of, the prices change.
So, basically, there are three possible options for "memberof": "WNA", "WAPNAP", and "Non." And there are always three options for "conferenceoption":
"Two Days (Friday & Saturday)($someprice)"
"Friday Only ($someprice)"
"Saturday Only ($someprice)"
The value of "someprice" changes depending on what's selected in memberof.
So, I've got code that sets the options in conferenceoption depending on the value in memberof, using an array. That code works.
What doesn't work is my efforts to keep the value in conferenceoption the same. That is, if a person selects "Friday Only" in conferenceoption, then selects "WNA" in memberoption, I want the code to change the options in conferenceoption to show the WNA prices, and then re-select "Friday Only." But it doesn't do that: it changes the options, then sets the value back to "Two Days," which is the first option in the list.
Here's the code that's not working. I have tried several variations; this particular variation is the one recommended for automatically setting values, but it's giving me a runtime error ("'options[...]' is null or not an object"
:
[tt]
[/tt]
Please help. Thanks in advance.
Katie
I'm kind of new to JavaScript - more of a VB programmer. So this may be a simple fix; I don't know.
I've got a form (pharmreg) that has two select boxes (memberof and conferenceoption). The options in conferenceoption depend on the value selected in memberof, because depending on what you are a member of, the prices change.
So, basically, there are three possible options for "memberof": "WNA", "WAPNAP", and "Non." And there are always three options for "conferenceoption":
"Two Days (Friday & Saturday)($someprice)"
"Friday Only ($someprice)"
"Saturday Only ($someprice)"
The value of "someprice" changes depending on what's selected in memberof.
So, I've got code that sets the options in conferenceoption depending on the value in memberof, using an array. That code works.
What doesn't work is my efforts to keep the value in conferenceoption the same. That is, if a person selects "Friday Only" in conferenceoption, then selects "WNA" in memberoption, I want the code to change the options in conferenceoption to show the WNA prices, and then re-select "Friday Only." But it doesn't do that: it changes the options, then sets the value back to "Two Days," which is the first option in the list.
Here's the code that's not working. I have tried several variations; this particular variation is the one recommended for automatically setting values, but it's giving me a runtime error ("'options[...]' is null or not an object"

[tt]
Code:
function SelectControlOption(selectCtrl,optionindex) {
selectCtrl.options[optionindex].selected='true';
}
function SetPriceDisplays() {
var ctlconfoption=document.forms.pharmreg.conferenceoption;
var currentconfindex=ctlconfoption.selectedindex;
switch(document.forms.pharmreg.memberof.value) {
case "WNA": { fillSelectFromArray(document.forms.pharmreg.conferenceoption, confvalue[0]); break; }
case "WAPNAP": { fillSelectFromArray(document.forms.pharmreg.conferenceoption, confvalue[1]); break; }
case "Non": { fillSelectFromArray(document.forms.pharmreg.conferenceoption, confvalue[2]); break; }
}
SelectControlOption(ctlconfoption,currentconfindex);
}
// here's a bunch of irrelevant form code. following is html.
<tr>
<td width="75"></td>
<td align="left" width="100"><font class="smalltext"><b>:</b></font></td>
<td align="left" width="450">
<select size="1" name="memberof" onchange=SetPriceDisplays()>
<option value="WNA">WNA Member</option>
<option value="WAPNAP">WAPNAP Member</option>
<option value="Non" selected="selected">Non-Member</option>
</select>
</td>
</tr>
<tr>
<td width="75"></td>
<td align="left" width="100"><font class="smalltext"><b>:</b></font></td>
<td align="left" width="450">
<select size="1" name="conferenceoption">
<option value="Two Days"> </option>
<option value="Friday"> </option>
<option value="Saturday"> </option>
</select>
</td>
</tr>
Please help. Thanks in advance.
Katie