Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2004
    Location
    Kentucky
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How do I set a combobox to specific index

    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
    ......
    -- Always thankful for kind and patient teachers willing to help a beginner.

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    626
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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>

  • #3
    New Coder
    Join Date
    Jan 2004
    Location
    Kentucky
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks requestcode.

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

    Works great now!
    -- Always thankful for kind and patient teachers willing to help a beginner.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •