【问题标题】:Accessing text from entry in a jquery.ui dialog box从 jquery.ui 对话框中的条目访问文本
【发布时间】:2011-11-23 07:40:26
【问题描述】:

如何从 jquery.ui 对话框中获取文本数据? 我已经挑出了不起作用的调用,并包含了所有脚本链接以显示我正在使用的内容。尽管对话框中的文本输入有效,但它不会传递到包含它的表单。如您所见,我尝试将其复制到对话框外的字段中,但不起作用。我真正想做的是将它像表单中的其他数据一样发布到操作页面。

这是网址:http://dev.bizzocall.com/cp-BizzoActiveButtonSIMPLE.php

代码:

<?php require_once('Connections/bizCon.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
mysql_select_db($database_bizCon, $bizCon);
$query_buttonPrefsSet = "SELECT buttonprefs.iduserid, buttonprefs.btop, buttonprefs.bleft, buttonprefs.bcolor, buttonprefs.blabel, buttonprefs.newvisitors, buttonprefs.bdelay, buttonprefs.brepeats, buttonprefs.btype, buttonprefs.bphonetarget FROM buttonprefs ORDER BY buttonprefs.iduserid DESC LIMIT 1";
$buttonPrefsSet = mysql_query($query_buttonPrefsSet, $bizCon) or die(mysql_error());
$row_buttonPrefsSet = mysql_fetch_assoc($buttonPrefsSet);
$totalRows_buttonPrefsSet = mysql_num_rows($buttonPrefsSet);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<title>Bizzo Control Panel</title>
<link href="css/plan.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" href="css/BizzocallPopup.css" type="text/css"/>
<link href="css/cpanel.css" rel="stylesheet" type="text/css"/>
<link href="css/BizzocallPopup.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
<script src="Draggable/development-bundle/ui/jquery.ui.core.js"></script>
<script src="Draggable/development-bundle/ui/jquery.ui.widget.js"></script>
<script src="Draggable/development-bundle/ui/jquery.ui.mouse.js"></script>
<script src="Draggable/development-bundle/ui/jquery.ui.draggable.js"></script>
<link type="text/css" href="css/jquery-ui-1.8.16.custom.css" rel="stylesheet" />
<script type="text/javascript" src="/js/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript">
            $(function(){
                // Dialog           
                $('#labelStgdialog').dialog({
                    autoOpen: false,
                    width: 400,
                    buttons: {
                        "OK": function() { 

                            $(this).dialog("close"); 
                        } 
                    }
                });

                // Dialog Link
                $('#labelSetgbtn').click(function(){
                    $('#labelStgdialog').dialog('open');
                    return false;
                });

            });

            $('#enterlabel').change(function() {
             $("input#blabel").val($("input#enterlabel;").val());
});
        </script>
</head>
<body>
<div class="contentWrapper">
  <form action="cp-BizzoEmbedCodeSIMPLE.php" method="post" enctype="multipart/form-data" name="buttonprefform" target="_top">
    <div id="labelSetgbtn" class="button gray LabelSettings"><a href="#">LABEL SETTINGS</a></div>
    <div id="labelStgdialog" class="DialogBox">
      <div class="boldtxt">ENTER YOUR CUSTOM LABEL</div>
      <div class="labeltxtblack">CALL&nbsp;&nbsp;&nbsp;</div>
      <input name="enterlabel" type="text" id="enterlabel" class="enterlabel" value=" > 10 char "  maxlength="9" length="10"/>
      <div class="clearer"></div>
      <div class="space10"></div>
      <div class="bcpopuptop">
        <div class="bcsquare">
          <div class="innersquare"></div>
        </div>
        <div class="btnlabeltxt">CALL NOW</div>
      </div>
    </div>
    <input id="blabel" name="blabel" type="text" value="<?php echo strtoupper($row_buttonPrefsSet['blabel']); ?>" />
    <button name="mysubmitbutton" id="mysubmitbutton" type="submit" class="createbizzobutton"> </button>
  </form>
</div>
<!--END contentwrapper-->
</body>
</html>

【问题讨论】:

    标签: forms text jquery-ui-dialog


    【解决方案1】:

    这一行

    $("input#blabel").val($("input#enterlabel;").val());

    应该是

    $("input#blabel").val($("input#enterlabel").val());

    ?

    【讨论】:

    • 好收获!我必须通读几次代码才能看到 lil ';'傻瓜!但这并不能解决问题。
    • 我找到了一种方法。让我分享它,希望它会帮助某人。我把
      标签放在调用对话框的 div 之后(id“labelStgdialog”)。这个对话框有一个 id="enterlabel" 的文本输入字段(不是表单字段)。然后,我更改了代码对话框的“确定”按钮将字段 id“enterlabel”复制到表单字段 id 'blabel',它位于表单内部并绑定到数据库。当我让页面的其余部分完全正常工作时,我会发布一个链接。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-25
    • 1970-01-01
    • 2010-11-13
    相关资源
    最近更新 更多