I have two set of radio button in my html form and I am displaying a hidden div depends upon the radio button selection.And the hidden div ONLY display if both radio buttons are clicked.I am using a jquery to trigger click if the radio buttons are clicked
But when ever I load the page, the buttons are getting checked as expected and it not triggering the click event. due to which a user has to check the radio buttons again(eventhough they are selected).
My html code for radio buttons:
<div class=block>
<input onClick=show_seq_lunid(); type=radio name=button1 value=Yes <?php if(!isset($_POST['button1']) || (isset($_POST['button1']) && $_POST['button1'] == 'Yes')) echo ' checked=checked'?> checked /><label>Yes</label>
<input onClick=show_list_lunid(); type=radio name=button1 value=No <?php if(isset($_POST['button1']) && $_POST['button1'] == 'No') echo ' checked=checked';?> /><label>No</label>
</div>
<div class=block>
<input onClick=os_others(); type=radio name=button2 value=Yes <?php if(!isset($_POST['button2']) || (isset($_POST['button2']) && $_POST['button2'] == 'Yes')) echo ' checked=checked'?> checked /><label>Others</label>
<input onClick=os_hpux(); type=radio name=button2 value=No <?php if(isset($_POST['button2']) && $_POST['button2'] == 'No') echo ' checked=checked';?> /><label>HP-UNIX</label>
</div>
And I tried below code to trigger click event for a checked radio button
$('input:radio[name=button1]:checked').click();
$('input:radio[name=button2]:checked').click();
but it is not working. How can I trigger the click event ?
Update:
Tried in DOM ready mode using code below, but no luck
$(document).ready(function() {
$('input:radio[name=button1]:checked').click();
$('input:radio[name=button2]:checked').click();
});