Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2005
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    report for the selected checkboxes

    Hi this is my first post in this site, and i whish you help me
    i have the following html page and i need a script that create a window
    showing the selected items as a sentence , also with "Print" & "Close" buttons
    -----------------------------------------------

    <html>

    <head>
    </head>

    <body>

    <form method="POST">
    Inquiry Details : <br>
    <br>
    <input type="checkbox" name="shoes" value="ON"> Shoes<br>
    <input type="checkbox" name="tshirt" value="ON"> T-shirt</p>
    <p><select size="1" name="accessories">
    <option selected>Accessories</option>
    <option value="Belt">Watch</option>
    <option>Blue</option>
    </select><br>
    </p>
    <p><select size="1" name="Glasses">
    <option value="Nike">Nike</option>
    <option>Reyban</option>
    <option value="Police">Police</option>
    <option selected>Glasses</option>
    </select><br></p>
    <p>
    <input type="submit" value="Report" name="B1" style="border-style: ridge; border-width: 1"></p>
    </form>

    </body>

    </html>
    ----------------------


    Regards,

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    welcome to the forum.

    Try this:

    in main page
    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd">
    <
    html>
    <
    head>
    <
    title>Untitled Document</title>
    <
    meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <
    meta http-equiv="Content-Style-Type" content="text/css">
    <
    meta http-equiv="Content-Script-Type" content="text/javascript">
    <
    script language="JavaScript" type="text/JavaScript">
    var 
    items = new Array()
    function 
    popS(f){
    var 
    sa=f.accessories.selectedIndex;
    var 
    sg=f.Glasses.selectedIndex;
    var 
    i=0;
    if(
    f.shoes.checked){items[i]=f.shoes.name;i++}
    if(
    f.tshirt.checked){items[i]=f.tshirt.name;i++}
    if(
    sa>0){items[i]=f.accessories.options[sa].text;i++}
    if(
    sg>0){items[i]=f.Glasses.options[sg].text;}
    var 
    popU window.open('pop.html','newwin','height=200 width=150')

    }
    </script>
    </head>
    <body>
    <form method="POST">
    Inquiry Details : <br>
    <br>
    <input type="checkbox" name="shoes" value="ON">Shoes<br>
    <input type="checkbox" name="tshirt" value="ON"> T-shirt</p>
    <p><select size="1" name="accessories">
    <option selected>Accessories</option>
    <option value="Belt">Watch</option>
    <option>Blue</option>
    </select><br>
    </p>
    <p><select size="1" name="Glasses">
    <option selected>Glasses</option>
    <option value="Nike">Nike</option>
    <option>Reyban</option>
    <option value="Police">Police</option>
    </select><br></p>
    <p>
    <input name="" type="button" value="Show me the selected" onclick="popS(this.form)">
    <input type="submit" value="Report" name="B1" style="border-style: ridge; border-width: 1"></p>
    </form>
    </body>
    </html> 
    in pop up page (called pop.html):
    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <
    html>
    <
    head>
    <
    title>Untitled Document</title>
    <
    meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <
    meta http-equiv="Content-Style-Type" content="text/css">
    <
    meta http-equiv="Content-Script-Type" content="text/javascript">
    <
    script language="JavaScript" type="text/JavaScript">
    onload=function(){
    var 
    root=document.getElementById('content');
    for(var 
    j=0;j<opener.items.length;j++){
    var 
    oTxt=document.createTextNode(opener.items[j]);
    var 
    oBr=document.createElement('br');
    root.appendChild(oTxt);root.appendChild(oBr);

    }
    </script>
    </head>
    <body>
    <div id="content"></div><br>
    <br>
    <input name="" type="button" value="Print" onclick="self.print()"><input name="" type="button" value="Close" onclick="self.close()">
    </body>
    </html> 
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New Coder
    Join Date
    Mar 2005
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you very much, it is working 100%


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •