Based on Particular Radio Button Selection Hide/Unhide Textboxes,Labels etc.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sahilansari
    New Member
    • Mar 2010
    • 5

    Based on Particular Radio Button Selection Hide/Unhide Textboxes,Labels etc.

    I have two Radio buttons. radio_date & radio _reg.

    Initially radio_date is checked by default.(On form load)....So i want to display two textboxes & related labels.All this data is in a table.As shown below.

    Code:
          <tr  > 
    	    <td >Date From   
    
             <input  type="text" name="date_from" id="date_from" value="<?php if($_POST['date_from'] != "") {print $_POST['date_from'];} else {print date('d-m-Y');} ?>" class="textboxes1" onClick="scwShow(this,event); " readonly="yes"/>
                            To        
             <input  type="text" name="date_to" id="date_to" value="<?php if($_POST['date_to'] != "") {print $_POST['date_to'];} else {print date('d-m-Y');}?>" class="textboxes1" onClick="scwShow(this,event);"/>
    		 </td>
          </tr>


    But if the user selects radio_reg I want the above HTML code to disablle,ie textboxes do not show etc .& radio_reg related select & labels show.

    Code:
      <tr>
      <td  ....> Some thing </td>
     <td  ....> Some thing </td>
    </tr>


    I wan this to work onClick ...when user clicks on the radio button.
    Last edited by Dormilich; Mar 29 '10, 10:04 AM. Reason: Please use [code] tags when posting code
  • phvfl
    Recognized Expert New Member
    • Aug 2007
    • 173

    #2
    If you want to hide a group of controls the easiest way is to hide a parent element which only contains those controls. This is not easy due to you using tables.

    Since it seems that you want to leave the table cells visible you will need to get a reference to each element and then set the style.display property to 'none' e.g.
    Code:
    /* Set the variable el to the html element using getElementById or similar
    el.style.display = 'none';

    Comment

    Working...