Hey guys.
Cool forum. I am new to this forum and javascript. I am taking this beginng class and I am almost done with my program but I do not know how to have my child window call the function in the parent.html window. Well I have it call it but I want it to display the data below the buttons of the parentwindow under the line it makes and I do not want the parent window to dissapear and put the data on the new line. Plus I do not know how to display the data values I want..I want to call the function in the parent.html file window by clicking on the child window confirm order. And the have child window dissapear displaying the data in a row below the line and buttons of the first window that popped up. I have no way to understand this. can yu guys give me some good direction. Thank you.
parent.html
Code:
<HTML>
<HEAD>
<TITLE>Parent Window</TITLE>
</HEAD>
<BODY>
<CENTER>
<H2>Robert's Pizza Palace</H2>
<h5>Welcome!</h5>
<HR SIZE=5 WIDTH=90%>
</Center>
<TABLE>
<TD>
</TD>
<TD>
<PRE>
<FORM NAME="OrderForm">
<B>Name: </B><INPUT TYPE=TEXT NAME="name" ID="name">
<B>Address: </B><INPUT TYPE=TEXT NAME="address" ID="address">
<B>Phone: </B><INPUT TYPE=TEXT NAME="phone" ID="phone">
<B>Quantity Ordered: </B><INPUT TYPE=TEXT NAME="qtypizzas" ID="qtypizzas">
<B></B>
<INPUT type="button" value="Place Order" onClick="window.open('3b.html', 'ConfirmOrder','width=600,height=450')">
<INPUT TYPE="RESET" VALUE="Clear">
</PRE>
</FORM>
</TD>
</TABLE>
<HR SIZE=5 WIDTH=90%>
<script language="JavaScript">
function DisplayConfirmData()
//this function does not work
{
window.focus();
document.write("Qty" + " + ""Phone"+ " " + "Name");
document.write(QtyPizzas + Phone + Name);
}
</script>
</BODY>
</HTML>
child.html
Code:
<HTML>
<HEAD>
<TITLE>Pizza Order Confirmation</TITLE>
</HEAD>
<BODY>
<CENTER>
<H3>Robert's Pizza Palace!</H3>
<h5>Confirm Your Order Please.</h5>
<h5>Thank You!</h5>
<HR SIZE=5 WIDTH=90%>
</Center>
<TABLE>
<TD>
</TD>
<TD>
<PRE>
<SCRIPT language="JavaScript"><!--
var Name = window.opener.document.OrderForm.name.value
var Phone = window.opener.document.OrderForm.phone.value
var QtyPizzas = window.opener.document.OrderForm.qtypizzas.value
document.write ("Hello " + Name );
document.write (", You have ordered " + QtyPizzas + " pizzas.<br>");
document.write ("You will receive a call shortly at " + Phone + ".");
function CallParentWindowFunction()
{
//trying to pass values back to parent.html while it stays open?
window.parent.DisplayConfirmData(Name,Phone, QtyPizzas);
window.close();
return false;
}
</SCRIPT>
<INPUT TYPE="BUTTON" NAME="Order" VALUE="Confirm Order"
onclick="javascript:return CallParentWindowFunction();"/>
<INPUT TYPE="BUTTON" VALUE="Cancel"
onclick="window.close()">
</pre>
</table>
</body>
</html>
Last edited by jsnewby; 04-13-2009 at 03:23 AM..
|