Forum Moderators: open
The below script was provided by Gul_Dukat earlier tonight and it worked like a dream... it carries data across from a html form into a popup window and then runs the data through a php script.
<script type="text/javascript" language="JavaScript"> <!-- function DoThis12() { var myW = window.open("","myW","height=400,width=500,scrollbars=yes,resizable=yes,statusbar=yes,menubar=yes,toolbar=yes,dependent=yes") } --> </script>
And in your form tag
<form method="POST" action="index_quote_result.php?<?php echo $post php?>&<?php echo $code php?>&<?php echo $unit_size php?>" onsubmit="DoThis12()" target="myW" >
however I have another problem. The popup window delivers a live quote based on the input in the html form. The websurfer can then change some dropdowns on the form and click for another quote. If they don't close the original popup window with the quote in it, the new quote arrives in the same popup window which is now hidden behind the main browser window. How can I either adapt the above script to keep the popup window 'on top' or have the original popup window close when a new quote is requested?
Thanks again.
As Peb0 says you can set on myW the focus when call
Try so
<script type="text/javascript" language="JavaScript"> <!--
function DoThis12() { var myW = window.open("","myW","height=400,width=500,scrollbars=yes,resizable=yes,statusbar=yes,menubar=yes,toolbar=yes,dependent=yes") }
myW.focus()
-->
</script>
:-)
function DoThis12() {
var myW = window.open(
"","myW","height=400,width=500,scrollbars=yes,resizable=yes,statusbar=yes,menubar=yes,toolbar=yes,dependent=yes"
)
}
myW.focus()
The var keyword needs to be removed.
If not, then
myW becomes a local variable, and will be inaccessible outside the function. The last line will then produce an error. <script type="text/javascript" language="JavaScript">
<!--
function DoThis12() {
var myW = window.open("","myW","height=400,width=500,scrollbars=yes,resizable=yes,statusbar=yes,menubar=yes,toolbar=yes,dependent=yes")
myW.focus()
}
-->
</script>
..or perhaps the last line is meant to be inside the function.
Yesss, you're right, the line must be inside the function ... just a lapsus, sorry :(
function DoThis12() {
var myW = window.open(
"","myW","height=400,width=500,scrollbars=yes,resizable=yes,statusbar=yes,menubar=yes,toolbar=yes,dependent=yes"
)myW.focus()
}
greetings