我有一個表格顯示來自mysql表中的數據,它有一個字段,需要用戶輸入。每一行還包含一個div。表單然後有兩個功能。jquery發送輸入字段值到彈出頁面
的第一個功能是從哪個處理每一行中的輸入字段中的值,並將結果發送到該行的div在一個結果的形式
第一功能完美地工作的外部PHP頁顯示信息這裏是腳本:
<script type="text/javascript">
function get(row){ //row being processed, defined in onchange="get(x)"
$.post ('getpeopleinjobs.php',{ //data posted to external page
postvarposition: form["position"+row].value, //variable equal to input box, sent to external page
postvarjob: form["job"+row].value, //variable equal to input box, sent to external page
postvarperson: form["person"+row].value, //variable equal to drop down list, sent to external page
postrow: row}, //variable equal row being processed, sent to external page
function(output){
$('#training'+row).html(output).show(); //display external results in row div
});
}
</script>
我需要幫助的第二個功能。我需要再次重複相同的JavaScript功能。然而,我不想將行變量發送到外部頁面,而是想將它們發送到彈出頁面。當我點擊div中的這個功能時應該會觸發。
我有彈出下面的JavaScript。
<script type="text/javascript">
// Popup window code
function newPopup(url) {
popupWindow = window.open( url,'popUpWindow','height=400,width=1000,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=yes')
}
</script>
What I want to do is send the variables to the popup page, the same variables that were sent to the external page.
so what I am aiming for is something like this:
<script type="text/javascript">
// Popup window code
function newPopup(url) {
function get(row){ //row being processed, defined in onchange="get(x)"
$.post ('trainingneeded.php',{ //my popup page
postvarposition: form["position"+row].value, //these variables must be posted to the popup page
postvarjob: form["job"+row].value, //these variables must be posted to the popup page
postvarperson: form["person"+row].value, //these variables must be posted to the popup page
postrow: row}, //these variables must be posted to the popup page
);
}
popupWindow = window.open(//open popup with the above variables posted to it
url,'popUpWindow','height=400,width=1000,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=yes')
}
</script>
我怎樣才能得到上述工作?使用href是最好的主意,或者div可以使用onclick事件。
感謝您提前協助。