javascript - Preloaded radio button in Jquery -


i trying have 1 of 3 radio buttons checked, when page loads , if happen, want make actions there java code

if (variable.equals("d")) { top.setvariable("{vara}", "checked='checked'"); }else if (variable.equals("r")) { top.setvariable("{varb}", "checked='checked'"); }else if (variable.equals("a")) { top.setvariable("{varc}", "checked='checked'"); } 

and then, html code

<input name="radio" type="radio" value="d"" {vara}/> <input name="radio" type="radio" value="r"" {varb}/> <input name="radio" type="radio" value="a"" {varc}/> 

i want have when of radio button checked, hide or show part of pages when page loads; similar this

    if($j("input[name='radio'][value='d']").attr('checked','checked'))     {     $j("#div1").show();     $j("#div").hide();     }     else if($j("input[@name='radio'][value='a']").attr('checked','checked'))         {             $j("#div1").hide();             $j("#div").show();         } 

but, having inconsistencies, , right radio button checked, , wrong one, , wrong divs shown

any idea or solution this?

thanks

there mistake in code.

change :

$j("input[@name='radio'][value='a']" 

to

$j("input[name='radio'][value='a']" 

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -