【问题标题】:radio button value in jquery dialogjquery对话框中的单选按钮值
【发布时间】:2014-03-27 00:05:02
【问题描述】:

我在表单 jquery 对话框中使用无线电类型,像这样

<div id="updateDialog" title="Update">
   <div class="box-update">
      <form id="d-form" action="" method="post">
         <div class="group-r">
            <label for="employe_status" class="label-r">Status :</label>
            <div class="ctrl-radio">
               <input type="radio" value="New Employee" id="employe_statusradio1" name="employe_status" />
            </div>
            <div class="radio-txt for-w-small">New Employee</div>
            <div class="ctrl-radio">
               <input type="radio" value="Internaly Transitioning Employee" id="employe_statusradio2" name="employe_status" />
            </div>
            <div class="radio-txt">Internally Transitioning Employee</div>
            <font color="red">*</font>
         </div>
      </form>
   </div>

当对话框打开时,为什么收音机的值为空(我右键单击并检查元素),所以当我提交此表单时,没有帖子值....任何想法,请。谢谢

【问题讨论】:

  • 我们不能只用你的 html 标记 :)
  • 请准备一把小提琴
  • jsfiddle.net/5h8CV 我有这样的概念......在小提琴中工作(值保持存在),但在我的系统中值变为空

标签: jquery html radio-button jquery-dialog


【解决方案1】:

您的代码有效:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js'></script>
        <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
        <link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" />
    </head>
    <body>
        <div id="updateDialog" title="Update">
            <div class="box-update">
                <form id="d-form" action="" method="post">
                    <div class="group-r">
                        <label for="employe_status" class="label-r">Status :</label>
                        <div class="ctrl-radio">
                            <input type="radio" value="New Employee" id="employe_statusradio1" name="employe_status" checked="checked" />
                        </div>
                        <div class="radio-txt for-w-small">New Employee</div>
                        <div class="ctrl-radio">
                            <input type="radio" value="Internaly Transitioning Employee" id="employe_statusradio2" name="employe_status" />
                        </div>
                        <div class="radio-txt">Internally Transitioning Employee</div> <font color="red">*</font>

                    </div>
                </form>
            </div>
        </div>
        <button id="update">Update</button>
    </body>
    <script type="text/javascript">
    $('#update').button().click(function () {
        $( '#updateDialog' ).dialog( 'open' );
        //alert();
    });

    $('#updateDialog').dialog({
        autoOpen: false,
        buttons: {
            'Update': function () {
                bValid = $("#d-form").valid();
                if (bValid) {
                    $('#ajaxLoadAni').fadeIn('slow');
                    $(this).dialog('close');
                    alert($('#employe_statusradio1').val() + $('#employe_statusradio2').val());

                } else {

                }
            },

                'Cancel': function () {
                $(this).dialog('close');
            }
        },
        width: '800px'
    }); //end update dialog    
    </script>
</html>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-02-12
    • 2014-02-20
    • 2012-04-02
    • 2017-07-28
    • 2012-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多