Labels = Radio button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fieryscream
    New Member
    • Sep 2009
    • 8

    Labels = Radio button

    Im doing some javascript coding for a project and i need to make a radio button
    selected when the corresponding label is clicked.

    any idea what the code is to do this?
  • RamananKalirajan
    Contributor
    • Mar 2008
    • 608

    #2
    You can do it like the following...

    HTML:
    Code:
    <input type="radio" id="label1Radio" value="some"><span id="label1" onclick="doThis(this.id)">Label1</span>
    JS:
    Code:
    function doThis(id)
    	{
    		var xx = id+'Radio';
    		if(document.getElementById(xx).checked==true)
    			document.getElementById(xx).checked=false;
    		else
    			document.getElementById(xx).checked=true;	
    	}
    Thanks and Regards
    Ramanan Kalriajan

    Comment

    • gits
      Recognized Expert Moderator Expert
      • May 2007
      • 5390

      #3
      you might even do that without javascript ... have look here ...

      kind regards

      Comment

      • fieryscream
        New Member
        • Sep 2009
        • 8

        #4
        Ty

        thank you .. fixed my problem ^^

        Comment

        Working...