2013-04-01 22 views
1

作爲彈出窗口的按鈕的表格內容。 這個彈出對輸入表格,並鏈接到 另一頁的功能在這裏我表的例子如何從表格內容中獲取記錄作爲彈出窗體的數據並顯示

<div> 
    <table width="1023" height="248" border="1"> 
    <td><div align="center"><input type="button" onclick="popup_window_show('#sample', { pos : 'tag-right-down', parent : this, width : '270px' });" value="A1.8" /></td> 
    </table> 
</div> 

我喜歡這個

<div class="popup_window_css" id="sample"> 
<table class="popup_window_css"> 
<tr class="popup_window_css"> 
<td class="popup_window_css"> 
<div class="popup_window_css_head"><img src="images/close.gif" alt="" width="9" height="9" />Aksi</div> 
<div class="popup_window_css_body"><div style="border: 1px solid #808080; padding: 6px; background: #FFFFFF;"> 
<form method="post" action=""> 
<table> 
    <tr> 
    <td> Werehouse </td> 
    <tr> 
    <td> Posisi</td> 
    <td> <input type='text' name="p" value="" /></td> 
    </tr> 
    <tr> 
    <td> Product ID</td> 
    <td> <input type='text' name="id" /></td> 
    </tr> 
    <tr> 
    <td> Product Name</td> 
    <td> <input type='text' name="nama" /></td> 
    </tr> 
    <tr> 
    <td> Production Date</td> 
    <td> <input type='text' name="tgl" /></td> 
    </tr> 
    <tr> 
     <td colspan='2' align='right'> 
     <input type='submit' value= 'Save'> 
     <input type='reset' value='Reset' /> 
     <input type='button' value='view' onclick=\"window.location.href='#';\"/> 
     </td> 
    </tr> 
</table> 
</div></div> 

彈出的形式可以在此屏幕拍攝可以幫助你明白我的問題

https://www.dropbox.com/s/bwil302fdzhe0f5/New%20Picture%20%2829%29.bmp

我的問題

如何獲取按鈕值作爲彈出窗體的數據並自動顯示在窗體「posisi」?

+0

看起來,你是印尼),你可以給我們您popup_window_show功能? – Ricky

+0

是的,這是正確的我是印度尼西亞:) 這是我的彈出功能 https://www.dropbox.com/s/aqwltbyfzvqk7vg/popup-window.js – Andriansyah

+0

ic簡單的解決方案,但不是最好的,設置變量上的JavaScript ,並設置你的按鈕值,當彈出觸發,獲得該變量值爲「posisi」 – Ricky

回答

1

TQ瑞奇這個答案

<script> 
    function setvalue(values) { 
    document.getElementById('posisi').value = values; 
} 
</script> 
<div> 
    <table width="1023" height="248" border="1"> 
     <tr> 
      <td> 

        <input type="button" onclick="setvalue(this.value);" value="A1.8" /> 
      </td> 
     </tr> 
    </table> 
    </div> 
    <div class="popup_window_css" id="sample"> 
     <table class="popup_window_css"> 
      <tr class="popup_window_css"> 
       <td class="popup_window_css"> 
        <div class="popup_window_css_head"> 
         <img src="images/close.gif" alt="" width="9" height="9" />Aksi</div> 
        <div class="popup_window_css_body"> 
         <div style="border: 1px solid #808080; padding: 6px; background: #FFFFFF;"> 
          <form method="post" action=""> 
           <table> 
            <tr> 
             <td>Werehouse</td> 
             <tr> 
              <td>Posisi</td> 
              <td> 
               <input type='text' name="p" id="posisi" /> 
              </td> 
             </tr> 
             <tr> 
              <td>Product ID</td> 
              <td> 
               <input type='text' name="id" /> 
              </td> 
             </tr> 
             <tr> 
              <td>Product Name</td> 
              <td> 
               <input type='text' name="nama" /> 
              </td> 
             </tr> 
             <tr> 
              <td>Production Date</td> 
              <td> 
               <input type='text' name="tgl" /> 
              </td> 
             </tr> 
             <tr> 
              <td colspan='2' align='right'> 
               <input type='submit' value='Save'> 
               <input type='reset' value='Reset' /> 
               <input type='button' value='view' onclick=\ "window.location.href='#';\"/> 
              </td> 
             </tr> 
           </table> 
         </div> 
        </div> 

您可以在這裏CEK http://jsfiddle.net/JLExZ/

0

您可以使用HTML5數據屬性概念在表單數據中設置值,如 ,並通過JavaScript接收數據。

<div id="awesome" 
data-hash="3e4ae6c4e30e50e4fdfc7bf439a09974">Some awesome data</div> 

    var dataHashValue = jQuery("#awesome").data('hash'); 
    console.log(dataHashValue); 
相關問題