The_Dude_1978 Posted July 29, 2012 Share Posted July 29, 2012 Hi there, I'm not an experienced scripter. What I've got is the following: a index page that calls the child window index.html <html> <head> <script language="javascript"> function openwindow() { retval=window.showModalDialog("popup.html") document.getElementById('text1').value=retval } </script> </head> <body> <input name=text1 type=text readonly> <input type=button onclick="javascript:openwindow()" value="Open window.."> </div> </body> </html> popup.html <html> <head> <script type="text/javascript"> function calculate(f) { var photo = f.photos; var ptext = f.photostext; var pitem = f.photositem; var result = 0; var items = ''; for(var i=0;i<photo.length;i++) { if(photo[i].checked) { result+=parseFloat(ptext[i].value); items+=pitem[i].value+'\n'; } } f.answer.value=Number(result).toFixed(2); //if you want to fix to 2 decimal places //f.answer.value=Number(result).toFixed(2); window.returnValue=f.allitems.value=items; } </script> <style type="text/css"> .box1 { float:left; width:500px; clear:left; } </style> <script language="javascript"> <!-- Hide from browsers lacking javascript window.onload=function() { document.getElementById("close").onclick=function(){window.close()}; }; // End hiding --> </script> </head> <body> <div id="photos"> <form name="myform" method="post" onSubmit="formSubmit()" > Choose the product options you want to order<br> <div class="box1"> <input type="checkbox" name="photos" id="photos" onclick="calculate(this.form)"> <input type="hidden" name="photostext" id="photostext" value="1.50" onchange="calculate(this.form)">15x15 (1,50) <input type="hidden" name="photositem" id="photositem" value="15x15" onchange="calculate(this.form)"> </div> <br> <div class="box1"> <input type="checkbox" name="photos" id="photos" onclick="calculate(this.form)"> <input type="hidden" name="photostext" id="photostext" value="2.00" onchange="calculate(this.form)">15x30 (2,00) <input type="hidden" name="photositem" id="photositem" value="15x30" onchange="calculate(this.form)"> </div><br> <div class="box1"> <input type="checkbox" name="photos" id="photos" onclick="calculate(this.form)"> <input type="hidden" name="photostext" id="photostext" value="3.20" onchange="calculate(this.form)">30x30 (3,20) <input type="hidden" name="photositem" id="photositem" value="30x30" onchange="calculate(this.form)"> </div><br> <div class="box1"> Total <input type="text" name="answer" size="5"><textarea name="allitems" rows="5"></textarea> </div> <div class="box1"> <input type="submit" name="close" value="submit" /> </div> </form> </div> </body> </html> With this code it sets the product after eachother without spaces in the textarea. And I can't seem to find out how to sort the data of each product into: Description (checkbox description) > product > price > Total I need this in table and in a form to post to the shopping cart. Can you help me out? Quote Link to comment https://forums.phpfreaks.com/topic/266421-how-to-sort-data-from-child-window/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.