【问题标题】:Radio button selected after submit a form提交表单后选择单选按钮
【发布时间】:2012-12-21 19:33:18
【问题描述】:

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.我在表单中的单选按钮代码如下所示。

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>';

现在我想在选择单选按钮时选择单选按钮。谢谢

【问题讨论】:

  • 我不明白这个问题。 “现在我想在选择单选按钮时选择单选按钮。谢谢”。这是什么意思?
  • 除了问题的可读性之外,请尝试使用唯一 id 以及 posts_displaydate
  • 当我选择单选按钮并提交表单时,值通过但我希望单选按钮也已选择,因为我选择了它是否已经提交。

标签: wordpress radio-button


【解决方案1】:

您需要使用 $posts_displaydate 来检查条件,如下所示,或者写下完整的代码,以便我编写。

if($posts_displaydate=='YES') echo "checked"; 
if($posts_displaydate=='NO') echo "checked";

【讨论】:

    猜你喜欢
    • 2012-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-20
    • 1970-01-01
    • 2013-10-06
    • 2016-05-31
    相关资源
    最近更新 更多