jhollin1138 Posted March 13, 2007 Share Posted March 13, 2007 I feel like a javascript knucklehead here. I am trying to implement the "Modal Dialog Box" script found here h**p://javascript.about.com/b/a/256836.htm. I have been able to get the front end of things working fine; it is the back end of things that isn't working. I am working on a script, in PHP, that is pulling information together and generates one of three different reports. I am using the "Modal Dialog Box" to generate an interface for the user to select which of the reports they want to generate. When the user clicks 'OK', I want to pop-up a new window with their report. Here is my HTML code for the "Modal Dialog Box". ><div id="box" class="dialog"> <form method="post" name="printDialog" action="printWin('./print.php?id=4306&PrintSheet=', 'order');"> <table align="center"> <tr><td colspan="2">Print Sheet: </td></tr> <tr><td colspan="2"><input type="radio" name="PrintSheet" value="order" checked="checked" /> Order</td></tr> <tr><td colspan="2"><input type="radio" name="PrintSheet" value="spec" /> Specification</td></tr> <tr><td colspan="2"><input type="radio" name="PrintSheet" value="est" /> Estimate</td></tr> <tr> <td> <input type="submit" name="submit" value="OK" onclick="hm('box');" /> </td> <td> <input type="reset" value="Cancel" onclick="hm('box');" /> </td> </tr> </table> </form> </div> Here is my javascript that is handling the pop-up window. >MyPrintWin=null; function printWin(linkName, printPageDefault) { if(MyPrintWin != null) MyPrintWin.close(); for (var i=0; i < document.printDialog.PrintSheet.length; i++) { if (document.printDialog.PrintSheet[i].checked) { var printPage = document.printDialog.PrintSheet[i].value; } } printPageLink = linkName + printPage; MyPrintWin = window.open(printPageLink, "printWindow", "width=700,height=500,menubar=no,resizable,toolbar=no,scrollbars"); } When I click 'OK', the "Modal Dialog Box" is disappearing, but the pop-up isn't showing up. If I change my javascript to: >MyPrintWin=null; function printWin(linkName, printPageDefault) { if(MyPrintWin != null) MyPrintWin.close(); printPageLink = linkName + printPageDefault; MyPrintWin = window.open(printPageLink, "printWindow", "width=700,height=500,menubar=no,resizable,toolbar=no,scrollbars"); } Everything works the way I would like, although obviously the value for the radio button is not being used. Am I missing something here? Quote Link to comment Share on other sites More sharing options...
jhollin1138 Posted March 13, 2007 Author Share Posted March 13, 2007 Here is an update. I tried the following javascript code, still no luck. >MyPrintWin=null; function printWin(linkName, printPageDefault) { if(MyPrintWin != null) MyPrintWin.close(); var printPage = printPageDefault; for (var i=0; i < document.printDialog.PrintSheet.length; i++) { if (document.printDialog.PrintSheet[i].checked) { printPage = document.printDialog.PrintSheet[i].value; } } printPageLink = linkName + printPage; MyPrintWin = window.open(printPageLink, "printWindow", "width=700,height=500,menubar=no,resizable,toolbar=no,scrollbars"); } I also tried using onsubmit instead of action in my html form, no luck. ><div id="box" class="dialog"> <form method="post" name="printDialog" onsubmit="printWin('./print.php?id=4306&PrintSheet=', 'spec');return false;"> <table align="center"> <tr><td colspan="2">Print Sheet: </td></tr> <tr><td colspan="2"><input type="radio" name="PrintSheet" value="order" checked="checked" /> Order</td></tr> <tr><td colspan="2"><input type="radio" name="PrintSheet" value="spec" /> Specification</td></tr> <tr><td colspan="2"><input type="radio" name="PrintSheet" value="est" /> Estimate</td></tr> <tr> <td> <input type="submit" name="submit" value="OK" onclick="java script:hm('box');" /> </td> <td> <input type="reset" value="Cancel" onclick="java script:hm('box');" /> </td> </tr> </table> </form> </div> Any help would be appreciated. Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted March 13, 2007 Share Posted March 13, 2007 Have you tried writing a cookie and reading it? Sounds like your variables are not being passed. Quote Link to comment Share on other sites More sharing options...
jhollin1138 Posted March 14, 2007 Author Share Posted March 14, 2007 Have you tried writing a cookie and reading it? Sounds like your variables are not being passed. Unfortunately, the only thing I know about cookies is how to eat them. Quote Link to comment Share on other sites More sharing options...
jhollin1138 Posted March 14, 2007 Author Share Posted March 14, 2007 I finally got everything working. The solution came to me when I was giving the kids a bath. Instead of trying to figure out which radio button was picked and set a variable, just set a variable. This is what I came up with for the html section: ><div id="box" class="dialog"> <form method="post" name="printDialog" action="printWin('./print.php?id=4306&PrintSheet=');"> <table align="center"> <tr><td colspan="2">Print Sheet: </td></tr> <tr><td colspan="2"><input type="radio" name="PrintSheet" onclick="printPage='order'" /> Order</td></tr> <tr><td colspan="2"><input type="radio" name="PrintSheet" onclick="printPage='spec'" /> Specification</td></tr> <tr><td colspan="2"><input type="radio" name="PrintSheet" onclick="printPage='est'" /> Estimate</td></tr> <tr> <td> <input type="submit" name="submit" value="OK" onclick="hm('box');" /> </td> <td> <input type="reset" value="Cancel" onclick="hm('box');" /> </td> </tr> </table> </form> </div> Here is the java script: >MyPrintWin=null; function printWin(linkName) { if(MyPrintWin != null) MyPrintWin.close(); printPageLink = linkName + printPage; MyPrintWin = window.open(printPageLink, "printWindow", "width=700,height=500,menubar=no,resizable,toolbar=no,scrollbars"); } Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted March 14, 2007 Share Posted March 14, 2007 Glad you found a solution. Quote Link to comment 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.