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”表单中?

4

2 回答 2

1

tq 为 Ricky 这就是答案

<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>

你可以在这里http://jsfiddle.net/JLExZ/

于 2013-04-12T09:42:30.433 回答
0

您可以使用 HTML5 数据属性概念在表单数据中设置值,例如通过 JavaScript 接收数据。

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

  var dataHashValue = jQuery("#awesome").data('hash');
     console.log(dataHashValue);
于 2013-04-01T06:58:02.997 回答