如何在HTML中使用javascrip在弹出窗口中显示标签的值 [英] how to display value of label in pop up window using javascrip in html

查看:56
本文介绍了如何在HTML中使用javascrip在弹出窗口中显示标签的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< pre lang ="Javascript">函数myPopup(){
window.open("popup.html","popupform",
状态= 1,高度= 300,宽度= 300,可调整大小= 0")
}</pre>


< table border ="1" bgcolor =#C0C0C0" cellpadding ="3" cellspacing ="3" width ="250">
< tr>
< th>选择</th>
< th>文档名称</th>
</tr>
< tr>
< td>& lt;输入type ="checkbox" ID ="chk1" name ="check1"/& gt;</td>
< td>& lt; label for ="chk1"& gt; Word File.doc& lt;/label& gt;</td>
</tr>
< tr>
< td>& lt;输入type ="checkbox" ID ="chk2" name ="check2"/& gt;</td>
< td>< label for ="chk1"& gt; PDF File.pdf& lt;/label& gt;</td>
</tr>
< tr>
< td>& lt;输入önClick="myPopup()" type ="submit" name ="button" value ="Print" width ="100px"</td>
</tr>
这是我的html标记和脚本.我想在每次选中复选框并单击button时在弹出窗口中显示标签的值,即"word file.doc".
提前致谢</table>

<pre lang="Javascript">function myPopup() {
window.open( "popup.html", "popupform",
"status = 1, height = 300, width = 300, resizable = 0" )
}</pre>


<table border="1" bgcolor="#C0C0C0" cellpadding="3" cellspacing="3" width="250">
<tr>
<th>Select</th>
<th>Document Name</th>
</tr>
<tr>
<td>&lt;input type="checkbox" ID="chk1" name="check1" /&gt;</td>
<td>&lt;label for="chk1"&gt;Word File.doc&lt;/label&gt;</td>
</tr>
<tr>
<td>&lt;input type="checkbox" ID="chk2" name="check2" /&gt;</td>
<td>&lt;label for="chk1"&gt;PDF File.pdf&lt;/label&gt;</td>
</tr>
<tr>
<td>&lt;input önClick="myPopup()" type="submit" name="button" value="Print" width="100px"&gt;</td>
</tr>
here is my html markup and script .i want to display value of label i.e"word file.doc" so on in pop up window whenever i check checkbox and click on button .
Thanks in Advance</table>

推荐答案

您好,

您可以尝试使用我的代码

Hi,

you try my code for that

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script language ="javascript" >
        function f1() {
            var str="";
            if (document.getElementById("CheckBox1").checked) {
               str =


(' label [for ="CheckBox1"]').text() } 如果(文档 .getElementById(" CheckBox2").checked){ str = str + " +
('label[for="CheckBox1"]').text() } if (document.getElementById("CheckBox2").checked) { str = str+" "+


(' label [for ="CheckBox2"]').text() } 警报(str); } < / 脚本 > < /head > < 正文 > < 表单 =" form1" runat >服务器" > < div > < =" 50%" < tr > < td > < 输入 =" CheckBox1" 类型 复选框" 名称 =" CheckBox1" / < /td > < td > < 标签 =" < > < /td > < /tr > < tr > < td > < 输入 =" CheckBox2" 类型 复选框" 名称 =" CheckBox1" / < /td > < td > < 标签 =" < > < /td > < /tr > < tr > < td =" 2" < 输入 =" =" 点击 =" / > < /td > < /tr > < /table > < /div > < /form > < /body > < /html >
('label[for="CheckBox2"]').text() } alert(str); } </script> </head> <body> <form id="form1" runat="server"> <div> <table width="50%"> <tr> <td> <input id="CheckBox1" type="checkbox" name="CheckBox1" /> </td> <td> <label for="CheckBox1">WordFile.doc</label> </td> </tr> <tr> <td> <input id="CheckBox2" type="checkbox" name="CheckBox1" /> </td> <td> <label for="CheckBox2">PdfFile.pdf</label> </td> </tr> <tr> <td colspan="2"> <input type ="button" value ="show pop up" onclick="f1()" /> </td> </tr> </table> </div> </form> </body> </html>



最好的



All the Best


这篇关于如何在HTML中使用javascrip在弹出窗口中显示标签的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆