Forum Moderators: open

Message Too Old, No Replies

changing form value in parent window from child window using ajax

         

heryanto

8:24 am on Jul 17, 2006 (gmt 0)

10+ Year Member



how to get data value that has been list in child window and would like to passing to form value in parent window

RonPK

1:40 pm on Jul 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello heryanto, welcome to WebmasterWorld!

I don't think you need AJAX for that. A simple line of javascript should be fine.

The value of a field can be read or set through

document.formname.fieldname.value
. So if the name of the form is myForm and the field is called myField, that would make
document.myForm.myField.value
.

A parent window can be addressed from a popup window through

window.opener
. So the full line of code would be
window.opener.document.myForm.myField.value = 'some value';

heryanto

3:30 am on Jul 18, 2006 (gmt 0)

10+ Year Member



if the list of data in child windows i written in php code that insert in table list how can i pass the value of variable into "window.opener.document.myfield.value='some value'"?

RonPK

5:18 am on Jul 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure whether I understand what you mean. But how about this:

window.opener.document.myForm.myField.value = '<?php echo $myVar;?>';