【问题标题】:Add php variable to JQuery UI diaglog box将 php 变量添加到 JQuery UI 对话框
【发布时间】:2014-08-27 01:45:57
【问题描述】:

如何将 php 变量添加到 Jquery UI 对话框模式框中, 例如,我有一个包含要插入数据库的信息的表单,当用户单击提交按钮时,插入查询将执行,一旦成功,我将在页面上显示 JQuery UI 模式框并询问用户是否要插入新项目, 但是如何用 php 值重定向页面呢?

这是模态框需要重定向的实际链接:home/purchase_order_pricing?code=eGx8t6gc2SI7

这是我的代码:

$code = $this-input->post('code');

<!doctype html>
<html lang='en'>
<head>
<meta charset='utf-8'>
<title>jQuery UI Dialog - Modal confirmation</title>
<link rel='stylesheet' href='//code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css'>
<script src='//code.jquery.com/jquery-1.10.2.js'></script>
<script src='//code.jquery.com/ui/1.11.0/jquery-ui.js'></script>

<script>
$(function() {
$( '#dialog-confirm' ).dialog({
    height: 50,
    width: 350,
    modal: true,
    resizable: true,
    dialogClass: 'no-close success-dialog',
buttons: {
'Yes': function() {
 window.location = 'home/purchase_order_pricing?code = $code';
},
No: function() {
$( this ).dialog( 'close' );
}
}
});
});
</script>

</head>
<body>
<div id='dialog-confirm' title='Add more items?'>
<p>asd</p>
</div>
<div id='popup-msg'>
    <div id='loading'>
        <h2>Loading...</h2>
        <h3>Please wait a few seconds.</h3>
    </div>  

</div>

</body>
</html>

【问题讨论】:

    标签: javascript php jquery modal-dialog


    【解决方案1】:

    您可以像这样将 php 变量传递给 javascript:

    <script>
    var code = "<?php echo $code; ?>";
    </script>
    

    你可以在你的javascript中使用变量code。这是你需要的吗?
    例如:

    window.location = 'home/purchase_order_pricing?code =' + code;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多