Reputation: 1724
I have a form where i used radio buttom and when radio buttom is selected and submit the buttom the value is pass but radio buttom not selected. My code for the radio buttom in the form is written bellow.
echo '<form name="posts_form" id="post_form" method="post" action="">';
echo $displaycategory = get_option('posts_displaycategory');
echo '<p>Display Date:<br><input type="radio" value="YES"';
echo $posts_displaydate . '" name="posts_displaydate" id="posts_displaydate" /> YES</p>';
echo '<input type="radio" value="NO"';
echo $posts_displaydate . '" name="posts_displaydate" id="posts_displaydate" /> NO</p>';
Now i want to select the radio buttom when i select the radio buttom.Thank you
Upvotes: 0
Views: 231
Reputation: 2129
you need to check the condition with $posts_displaydate like below or write down the full code so i will write.
if($posts_displaydate=='YES') echo "checked";
if($posts_displaydate=='NO') echo "checked";
Upvotes: 1