2014-07-06 2 views
0

PHP 변수를 Jquery UI 대화 상자 모달 상자 에 추가하려면 어떻게합니까? 예를 들어 사용자가 제출 단추를 클릭하면 삽입 쿼리를 데이터베이스에 삽입 할 정보가 들어있는 양식이 있습니다. JQuery UI 모달 상자가 페이지에 나타나서 사용자에게 새 항목을 삽입 할 것인지 묻습니다. 그러나 PHP 값으로 페이지를 리디렉션하는 방법은 무엇입니까?JQuery UI diaglog 상자에 PHP 변수 추가

이것은 모달 상자가 리디렉션해야하는 실제 링크입니다. home/purchase_order_pricing?

$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

당신은이 같은 자바 스크립트로 PHP 변수를 전달할 수 있습니다 :

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

하고 당신이 당신의 자바 스크립트에서 변수 code을 사용할 수 있습니다 코드 = eGx8t6gc2SI7

여기 내 코드입니다 . 그게 네가 필요한거야?
예 :

window.location = 'home/purchase_order_pricing?code =' + code; 
관련 문제