Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Data to a Child Window 1

Status
Not open for further replies.

Ditter

Programmer
Sep 11, 2000
16
0
0
FR
Help!

I'm working in IE 5.0 and I can't pass data to a child window. Here is the main idea:

The code for the parent window is:

function openCalendar(objReceiver){

child = window.open "calendar02.html","calendarWindow", "WIDTH=180, HEIGHT=250, RESIZABLE=YES, DEPENDENT=TRUE, MENUBAR=NO, LOCATION=NO, SCROLLBARS=NO, TITLEBAR=NO, HOTKEYS=NO");

window.child.calControl.receiver.value=objReceiver;

}


And the related link in form is:

<A HREF=&quot;#&quot; onClick='openCalendar(&quot;myForm.dateField&quot;);'><IMG SRC=&quot;calendar.gif&quot; NOBORDER></A>


Finally, the code for this hidden in the child window is:

<INPUT TYPE=HIDDEN NAME=receiver VALUE=&quot;&quot;>

So, why the child window never got the value set in the &quot;openCalendar()&quot; function?

Thanx! :) [sig][/sig]
 
A couple of reasons this didn't work. The following example works in IE and can be changed to work with NN pretty easily (not a problem for you though as you use IE5 :) )...

default.html
Code:
<html>
<head>
<script language=&quot;javascript&quot;>
 function fnCalendar(objReceiver){
  child = window.open(&quot;calendar2.html&quot;,&quot;calendarWindow&quot;, &quot;WIDTH=180,HEIGHT=250,RESIZABLE=YES,DEPENDENT=TRUE,MENUBAR=NO,LOCATION=NO,SCROLLBARS=NO,TITLEBAR=NO,HOTKEYS=NO&quot;);
  child.document.forms.calControl.receiver.value=objReceiver
 }
</script>
<body>
<form id=myForm name=myForm>
 <input type=text value=&quot;&quot; id=dateField name=myForm>
 <input type=button value=&quot;Click&quot; onClick=&quot;fnCalendar(dateField.value)&quot;>
</form>
</body>
</html>

calendar2.html
Code:
<html>
<body>
<form id=calControl name=calControl>
 <input type=text value=&quot;&quot; id=receiver name=receiver>
</form>
</body>
</html>

Points...
1- don't pass object names within quotes as you are simply passing the string not the object reference
2- the window name should come first (not window.child but simply child as the object child references window.child)
3- use the document statement to reference items within the body of the html. window is used for browser reference.

Hope this helps,
Rob [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top