enabled fields based on checkbox value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • colesslow
    New Member
    • Dec 2007
    • 8

    #1

    enabled fields based on checkbox value

    i hv this code..but it doesn't work..the idea is to make the combo enabled if checkboxes with value 1 is selected.can anyone help me with this..is it bcoz of my function?? thanks in advance..


    <tr>
    <td><input class="text field" type=radio value="0" name="type" onClick="chkBox ();">0 &nbsp;
    <input class="text field" type=radio value="1" name="type" onClick="chkBox ();">more<td></td>
    <td><SELECT class="text field" name="Experienc e" disabled="true" >
    <option value="" selected></option>
    <option value="0">0</option>
    <option value="1">1</option>
    <option value="2">2</option>
    </SELECT>Year(s)</td>
    </tr>



    below is the function

    function chkBox()
    {
    if(document.add Form.type.check ed=="0")
    {
    document.addFor m.Experience.di sabled=true;
    }
    else(document.a ddForm.type.che cked=="1")
    {
    document.addFor m>experience.di sabled=false;
    }
    }
  • shweta123
    Recognized Expert Contributor
    • Nov 2006
    • 692

    #2
    Hi,

    You can make a little modification in your code to make it work.

    Code:
     
      
      function chkBox()
       {
    	if(Not document.addForm.type.checked)
    	{
    	   document.addForm.Experience.disabled;
    	}
    	else(document.addForm.type.checked)
    	{
    	   document.addForm.experience.disabled = false;
    	}
    Originally posted by colesslow
    i hv this code..but it doesn't work..the idea is to make the combo enabled if checkboxes with value 1 is selected.can anyone help me with this..is it bcoz of my function?? thanks in advance..


    <tr>
    <td><input class="text field" type=radio value="0" name="type" onClick="chkBox ();">0 &nbsp;
    <input class="text field" type=radio value="1" name="type" onClick="chkBox ();">more<td></td>
    <td><SELECT class="text field" name="Experienc e" disabled="true" >
    <option value="" selected></option>
    <option value="0">0</option>
    <option value="1">1</option>
    <option value="2">2</option>
    </SELECT>Year(s)</td>
    </tr>



    below is the function

    function chkBox()
    {
    if(document.add Form.type.check ed=="0")
    {
    document.addFor m.Experience.di sabled=true;
    }
    else(document.a ddForm.type.che cked=="1")
    {
    document.addFor m>experience.di sabled=false;
    }
    }

    Comment

    • colesslow
      New Member
      • Dec 2007
      • 8

      #3
      hi~~thanks..
      it works...

      Comment

      Working...