2012-07-12 41 views
-1

我有一個表格顯示來自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事件。

感謝您提前協助。

回答

1

不,無法發佈到彈出窗口。你可以在url中包含這些變量,並將其作爲get。

也可以添加目標=「_空白」的形式,讓它打開一個新窗口的方式。

這不會是一個彈出窗口,但這些天的瀏覽器主要是阻止這些,或打開他們在標籤無論如何,所以它可能並不重要

另外一個選擇是與空白打開彈出,然後使用JavaScript來簡單地write()的頁面內容,它

參見:。asp.net/jQuery: post data with jQuery to a popup [IE]

相關問題