Click here to Skip to main content
15,890,897 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<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>
Posted
Updated 26-Oct-11 3:03am
v2

Hi,

you try my code for that

HTML
<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()
           }
           if (document.getElementById("CheckBox2").checked) {
               str = str+"  "+$('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
 
Share this answer
 
Comments
saffuraj 25-Oct-11 7:32am    
thanks a lot for responding Expert but it didn't work what i exactly want . i am again explaining you that i want to display "WordFile.doc" this value in pop up window when i click on check box and button.
Muralikrishna8811 25-Oct-11 8:22am    
hiis it not showing value in alert

window.open("popup.aspx?val=",)
saffuraj 25-Oct-11 9:38am    
hi, thanks
i am not working in asp.net only in html and javascript. i have two page one is parent.html and another is popup.html.in parent.html i have one table consisting of two column and 4 row .first row is caption in 2nd row 1st column check box next to it label i.e "word file.doc" exactly above same check box and label i.e."pdf file.pdf". in third row one button.now requirement is that when user check check box and click button the value of label i.e "word file.doc" vice verse get display in pop up window that user has selected this and that using javascript(please no jQuery out of context).
help will be appreciated
Muralikrishna8811 25-Oct-11 9:44am    
what is the code in popup.html

you can show that simple value in same page with popup div(without Jquery)

Hi,

I found one way for your requirement

in your parent.html
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script language ="javascript" >
        function f1() {
            var str = "";
            if (document.getElementById("CheckBox1").checked) {

                if (document.getElementsByTagName("label").item(0).getAttribute("for") == 'CheckBox1') {
                   str=str+document.getElementsByTagName("label").item(0).innerText;
                }
            }
            if (document.getElementById("CheckBox2").checked) {
                if (document.getElementsByTagName("label").item(1).getAttribute("for") == 'CheckBox2') {
                    str=str+"  "+document.getElementsByTagName("label").item(1).innerText;
                }
            }
            alert(str);
            document.cookie = str;
            var win=window.open("popup.html", "popupform",
"status = 1, height = 300, width = 300, resizable = 0")
        }

    </script>
</head>
<body>
 <table width="50%">
      <tr>
       <td>
        
          <input id="CheckBox1" type="checkbox" name="CheckBox1" />
         
        
       </td>
       <td>
           <label id="sdt" 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>
</body>
</html>


And in your popup.html contains following code

HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script language ="javascript" >
        function f1() {
            var str = document.cookie.split(';');

            document.getElementById("resdiv").innerHTML = str[0];
        }
    </script>
</head>
<body onload="f1()">
Your selected File Names are : <div id="resdiv"></div>

</body>
</html>


Here I used only javascript

but it is not recommended

All the Best
 
Share this answer
 
Comments
saffuraj 26-Oct-11 2:32am    
thanks a lot Muralikrishna .your answer helped me lot .
Muralikrishna8811 26-Oct-11 6:43am    
most welcome

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900