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 5 of 5
  1. #1
    New Coder
    Join Date
    Mar 2005
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    popup window problem

    hi,

    i have a script with some checkboxes and textbox , the function of the script is to get some calculations , this script is in the following page: http://www.geocities.com/breemo22/Prices.html

    my problem is : the total is not showing in the popup

    here is the popup code "pop.html" :

    <html>
    <head>
    <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>
    <br><br>
    <input name="" type="button" value="Print" onclick="self.print()"><input name="" type="button" value="Close" onclick="self.close()">
    </body>
    </html>


    please help


    Regards

    reasr

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,534
    Thanks
    3
    Thanked 513 Times in 500 Posts
    I'm having a look at this but seems a difficukt way of meeting objective

    see

    http://www.vicsjavascripts.org.uk/Po...pGenerator.htm

    the Any HTML bit

    back later

  • #3
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,534
    Thanks
    3
    Thanked 513 Times in 500 Posts
    not sure what I have done but this works

    PHP Code:

    <HTML>
    <
    HEAD><TITLE>Prices</TITLE>
    <
    META content="text/html; charset=windows-1252" http-equiv=Content-Type>
    <
    SCRIPT>
    var 
    items = new Array()
    function 
    popS(f){
     var 
    sa=f.Accessories.selectedIndex;
     var 
    i=0;
     if(
    f.shoes.checked){ items[i]=f.shoes.value;i++}
     if(
    f.tshirt.checked){items[i]=f.tshirt.value;i++}
     if(
    f.watch.checked){items[i]=f.watch.value;i++}
     if(
    sa>0){
      
    items[i]=f.Accessories.options[sa].text;
      
    i++
     }
     
    alert(items)
     var 
    popU window.open('pop.html','newwin','height=400 width=400')
    }
    </SCRIPT>

    <SCRIPT>
    function count()
    {
    if (calc.tshirt.checked){ var wtshirt = document.calc.tshirt.value = 1600;}
        else{ var wtshirt = document.calc.tshirt.value = 0;}

    if (calc.watch.checked){ var wwatch = document.calc.watch.value = 370;}
        else{ var wwatch = document.calc.watch.value = 0;}

    if (calc.shoes.checked){ var wshoes = document.calc.shoes.value = 6590;}
         else{ var wshoes = document.calc.shoes.value = 0;}

    document.calc.pay.value = wshoes + wtshirt + wwatch + parseFloat(document.getElementById("total").value);

    }





    </SCRIPT>

    <META content="MSHTML 5.00.3700.6699" name=GENERATOR></HEAD>

    <BODY bgColor=#008080>


    <P align=center>prices</P>
    <FORM name=calc>
    <INPUT name=shoes type=checkbox value=Shoes >Shoes<BR>
    <INPUT name=tshirt type=checkbox value=T-shirt >T-shirt<BR>
    <INPUT name=watch type=checkbox value=Watch >Watch<BR>Accessories :<BR>
    <SELECT id=Accessories name=Accessories onchange=update_total()>
    <OPTION dir=rtl selected  value=0>Accessores --------------------</OPTION>
    <OPTION dir=rtl value=600>Pen</OPTION>
    <OPTION dir=rtl value=370>Mobile</OPTION>
    <OPTION dir=rtl value=0>None</OPTION>
    </SELECT>
    <BR>
    <BR>Price of Accessory:<BR>
    <INPUT id=total name=total> <BR>
    <BR>
    &nbsp;<INPUT id=pay name=pay>
    <INPUT onclick=count() type=button value="Total Price">
    <INPUT onclick=popS(this.form) type=button value=Report>
    </FORM>

    <SCRIPT>
    function update_total()
    {
    document.getElementById("total").value=parseFloat(document.getElementById("Accessories").value);
    }
    update_total();
    </SCRIPT>
    </BODY>
    </HTML> 

    PHP Code:
    <html>
    <
    head>
    <
    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>
    <br><br>
    <input name="" type="button" value="Print" onclick="self.print()"><input name="" type="button" value="Close" onclick="self.close()">
    </body>
    </html> 

  • #4
    New Coder
    Join Date
    Mar 2005
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    but still the total not shows on the popup!!

  • #5
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,534
    Thanks
    3
    Thanked 513 Times in 500 Posts
    PHP Code:
    <SCRIPT>
    var 
    items = new Array()
    function 
    popS(f){
     
    count();
     var 
    sa=f.Accessories.selectedIndex;
     var 
    i=0;
     if(
    f.shoes.checked){ items[i]=f.shoes.value;i++}
     if(
    f.tshirt.checked){items[i]=f.tshirt.value;i++}
     if(
    f.watch.checked){items[i]=f.watch.value;i++}
     if(
    sa>0){
      
    items[i]=f.Accessories.options[sa].text;
      
    i++
     }
     
    items[i]=f.pay.value
     alert
    (items)
     var 
    popU window.open('pop.html','newwin','height=400 width=400')
    }
    </SCRIPT> 


  •  

    Posting Permissions

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