Click to See Complete Forum and Search --> : pop-up's again


David Harrison
01-17-2003, 09:40 AM
I have a problem,

I have a window that has a button in it, when you click it, it opens a pop-up window with a form in it, you fill in the information an press sumbit and another pop-up window opens with the appropriate response in it, that's fine but in the first pop-up window, when submit is pressed, in the same window it loads the original window. How can I stop this from happening?

It it's not clear what I mean tell me and I'll upload the files that will hopefully explain what I mean.

mawood
01-17-2003, 09:43 AM
Sounds like a window name is being used more than once.

David Harrison
01-17-2003, 01:28 PM
i can't find anything like that, get the attachment to see what I mean, or you can jujst look at the source:



<html>
<head>

<script language="javascript">

function Popup(){

Popup = window.open("","PopUp","height=300, width=400, scrollbars=yes, resizable=yes, status=yes");
Popup.document.writeln("<html><head><script language=\"javascript\">");
Popup.document.writeln();
Popup.document.writeln("function Addup(){");
Popup.document.writeln();
Popup.document.writeln("a=addup.a.value;");
Popup.document.writeln("b=addup.b.value;");
Popup.document.writeln();
Popup.document.writeln(" Addup = window.open('','AddUp','height=300, width=400, scrollbars=yes, resizable=yes, status=yes');");
Popup.document.writeln(" Addup.document.writeln('<html><head><title>Add Up</title></head><body onload=\\'create(this.form)\\'>');");
Popup.document.writeln(" Addup.document.writeln('<p align=\\'center\\'><font face=\\'verdana\\' size=\\'4\\'><b>Add Up</b></font></p>');");
Popup.document.writeln();
Popup.document.writeln(" Addup.document.writeln((1*a)+(1*b))");
Popup.document.writeln();
Popup.document.writeln(" Addup.document.writeln('<p align=\\'center\\'><font face=\\'verdana\\'><a href=\\'javascript:window.close();\\'>Close</a></font></p></body></html>');}");
Popup.document.writeln();
Popup.document.writeln();
Popup.document.writeln("</script"+"><title>Pop-Up</title></head><body onload=\"create(this.form)\">");
Popup.document.writeln("<p align=\"center\"><font face=\"verdana\" size=\"4\"><b>Pop-Up</b></font></p>");
Popup.document.writeln();
Popup.document.writeln("<form name=\"addup\">");
Popup.document.writeln();
Popup.document.writeln("<input type=\"text\" name=\"a\" size=\"20\"> + ");
Popup.document.writeln();
Popup.document.writeln("<input type=\"text\" name=\"b\" size=\"20\"> = ??? ");
Popup.document.writeln();
Popup.document.writeln("<input type=\"submit\" value=\"Add Up\" onclick=\"Addup();\">");
Popup.document.writeln();
Popup.document.writeln("</form>");
Popup.document.writeln();
Popup.document.writeln("<p align=\"center\"><font face=\"verdana\"><a href=\"javascript:window.close();\">Close</a></font></p></body></html>");}



</script>

</head>

<body>

<form name="popup">

<input type="submit" value="Click Here To Add Stuff Up" onclick="Popup();">

</form>

</body></html>



see anything wrong?

mawood
01-17-2003, 02:04 PM
<html>
<head>

<script language="javascript">

function Popup(){

Popup = window.open("","PopUp","height=300, width=400, scrollbars=yes, resizable=yes, status=yes");
Popup.document.writeln("<html><head><script language=\"javascript\">");
Popup.document.writeln();
Popup.document.writeln("function Addup(){");
Popup.document.writeln();
Popup.document.writeln("a=addup.a.value;");
Popup.document.writeln("b=addup.b.value;");
Popup.document.writeln();
Popup.document.writeln(" Addup = window.open('','AddUp','height=300, width=400, scrollbars=yes, resizable=yes, status=yes');");
Popup.document.writeln(" Addup.document.writeln('<html><head><title>Add Up</title></head><body>');");
Popup.document.writeln(" Addup.document.writeln('<p align=\\'center\\'><font face=\\'verdana\\' size=\\'4\\'><b>Add Up</b></font></p>');");
Popup.document.writeln();
Popup.document.writeln(" Addup.document.writeln((1*a)+(1*b))");
Popup.document.writeln();
Popup.document.writeln(" Addup.document.writeln('<p align=\\'center\\'><font face=\\'verdana\\'><a href=\\'javascript:window.close();\\'>Close</a></font></p></body></html>');");
Popup.document.writeln("return false");
Popup.document.writeln("}");
Popup.document.writeln("</script"+"><title>Pop-Up</title></head><body>");
Popup.document.writeln("<p align=\"center\"><font face=\"verdana\" size=\"4\"><b>Pop-Up</b></font></p>");
Popup.document.writeln();
Popup.document.writeln("<form name=\"addup\">");
Popup.document.writeln();
Popup.document.writeln("<input type=\"text\" name=\"a\" size=\"20\"> + ");
Popup.document.writeln();
Popup.document.writeln("<input type=\"text\" name=\"b\" size=\"20\"> = ??? ");
Popup.document.writeln();
Popup.document.writeln("<input type=\"submit\" value=\"Add Up\" onclick=\"return Addup();\">");
Popup.document.writeln();
Popup.document.writeln("</form>");
Popup.document.writeln();
Popup.document.writeln("<p align=\"center\"><font face=\"verdana\"><a href=\"javascript:window.close();\">Close</a></font></p></body></html>");
}



</script>

</head>

<body>

<form name="popup">

<input type="submit" value="Click Here To Add Stuff Up" onclick="Popup();">

</form>

</body></html>

David Harrison
01-17-2003, 02:27 PM
Thanks it's now working but i don't understand why, all you seem to have done is delete all of the tab's that I used in my source.

David Harrison
01-17-2003, 02:29 PM
and the onload=\"create(this.form)\" in the body but that has no real effect, I don't know why it was there in the first place

David Harrison
01-17-2003, 02:36 PM
wait no I found it, it was something to do with return true, whatever that does, I don't know what it means but I've seen it in lots of places before but what does it do?

mawood
01-17-2003, 02:41 PM
needed to stop the submission of the form - return false.

David Harrison
01-17-2003, 02:47 PM
why would I want to STOP the submission of the form?

mawood
01-17-2003, 03:00 PM
Because you are using javascript to create the window with the answer. The page doesn't really exist since your script is creating it, therefore a form action is useless as there is no where for it to go. Hope this helps.