www.webdeveloper.com
Results 1 to 2 of 2

Thread: dosable a check box

  1. #1
    Join Date
    Oct 2011
    Posts
    2

    dosable a check box

    i am trying to disable a checkbox 1 when a particular drop down list 5th in the list is selected
    can u please help me with that


    Code:
    <div id="Div3">
                <label  class="pLabel">
                    Which of the following products have you purchased in the last 2 months. Please
                    check all that apply.<br/>
                </label>
                <span >
                <input  type="checkbox" name="CHKBOX_1" value="Product 1" id="Product1" tabindex="5" /> 
                   
                <label >
                    Product 1</label>
                <input  type="checkbox" name="CHKBOX_2" value="Product 2" id="Product2" tabindex="6"  />
                    
                <label >
                    Product 2</label>
                <input  type="checkbox" name="CHKBOX_3"  value="Product 3" id="Product3"tabindex="7" />
                    
                <label >
                    Product 3</label>
                    </span>
    				<br/><br/>
            </div>
    Code:
    <select name="age">
                    <option value="age">Please select your age</option>
                    <option value="18-24">18-24 </option>
                    <option value="25-34">25-34 </option>
                    <option value="35-50">35-50 </option>
    				<option value ="50+" > 50+ </option>
                    
                </select>
    Code:
    function validation(){
        if ( document.form77.age.selectedIndex == 0 )    {        
            alert ( "Please select your age." );        
                return false;    
                }
                if (document.form77.CHKBOX_1.checked == false && 
                        document.form77.CHKBOX_2.checked == false && 
                             document.form77.CHKBOX_3.checked == false){
                                 alert ('Please select a product 1 , 2 or 3');
     return false;
     }
     if (document.form77.age.selected == 4 ){
           document.form77.CHKBOX_1.checked.disabled == true;
           return false;
     }

  2. #2
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,266
    See http://www.w3schools.com/jsref/prop_...ox_checked.asp and write :
    Code:
    if (document.form77.age.selected == 4 ){
           document.form77.CHKBOX_1.checked = true;
           return false;}

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles