如何将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>
答案 0 :(得分:0)
您可以将php变量传递给javascript,如下所示:
<script>
var code = "<?php echo $code; ?>";
</script>
您可以在javascript中使用变量code
。这就是你需要的吗?
例如:
window.location = 'home/purchase_order_pricing?code =' + code;