...

View Full Version : How do I set a combobox to specific index



jwindon
01-15-2004, 04:19 PM
Having trouble getting this code to work. I want to return the combo box to the first selection. I do not get an error with this code, but is does not do the job.



........
function EnableFormFields(){
if(document.REG.wc_HAVETEAM[0].checked==true){//Yes have district team
document.REG.wc_MEET.disabled=false;
document.REG.wc_MEET.selectedindex=0;
document.REG.wc_OTHERMEET.disabled=false;
document.REG.wc.OTHERMEET.selectedIndex=0;
document.REG.wc_LEADSDISTRICT.disabled=false
......

requestcode
01-15-2004, 08:23 PM
It works for me. Are you sure the code is getting executed? You could also change your if to this:
if(document.REG.wc_HAVETEAM[0].checked)

That will determine if it has ben checked or not.

Here is an example that will disable a dropdown based on a radio button being checked.
<html>
<head>
<title>Test</title>
<SCRIPT LANGUAGE="JavaScript">
function check()
{
if(document.myform.chk[0].checked)
{
document.myform.dropd.blur()
document.myform.dropd.disabled=true
document.myform.dropd.selectedIndex=0
document.myform.drope.disabled=false
}
else
{
if(document.myform.chk[1].checked)
{
document.myform.drope.blur()
document.myform.drope.disabled=true
document.myform.drope.selectedIndex=0
document.myform.dropd.disabled=false
}
}
}
</SCRIPT>
</head>
<BODY BGCOLOR="lightgreen">
<CENTER>
<H1>Disable Drop Downs</H1>
<FORM name="myform">
<INPUT TYPE="radio" NAME="chk" onClick="check()" CHECKED>A
<INPUT TYPE="radio" NAME="chk" onClick="check()">B
<BR>
<SELECT NAME="dropd" onFocus="check()">
<OPTION SELECTED>Select One
<OPTION> Page One</OPTION>
<OPTION> Page Two</OPTION>
<OPTION> Page Three</OPTION>
</SELECT>
&nbsp &nbsp
<SELECT NAME="drope" onFocus="check()">
<OPTION SELECTED>Select One
<OPTION> Page One</OPTION>
<OPTION> Page Two</OPTION>
<OPTION> Page Three</OPTION>
</SELECT>

</FORM>
</CENTER>
</body>
</html>

jwindon
01-16-2004, 12:13 AM
Thanks requestcode.

You were right. I had a logic error AND a syntax error.

Works great now! :cool:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum