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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Child Window with some data from parent 1

Status
Not open for further replies.

ABinBoston

Programmer
Nov 6, 2001
22
US
I would like to open a new window from a parent form that contains several values from the parent form..

For example.. I'd like to add a new contact for a specific company, when I click the "add new contact" link, I'd like the new window that opens to have the values CompanyName and CompanyID.

I have seen code that will populate the parent form with the new contact info, what I want to do is the opposite.. I wish to populate the child withdata from the parent first..

Thanks! AB
 
I hope the following code will be helpful:

Code:
<HTML>
<HEAD>
	<TITLE>Untitled</TITLE>
<script language=&quot;javascript&quot;><!--

function subm() {
var openwindow = window.open(&quot;&quot;, &quot;newWin&quot;, config='height=200,width=200,menubar=yes,resizable');

var text
text = &quot;<html><head><title>New Window Title</title></head>&quot;
text += &quot;<body><form name='frm'>&quot;
text += &quot;<input type='text' name='co_name' value='&quot; + document.my_form.coName.value + &quot;'><br>&quot;
text += &quot;<input type='text' name='co_id' value='&quot; + document.my_form.coId.value + &quot;'><br>&quot;
text += &quot;</form></body></html>&quot;

openwindow.document.write(text)
openwindow.document.close()

}
//-->
</script>
</HEAD>

<BODY>
<form name=&quot;my_form&quot;>
<input type=&quot;text&quot; name=&quot;coName&quot; value=&quot;This is some name&quot;><br>
<input type=&quot;text&quot; name=&quot;coId&quot; value=&quot;This is some id&quot;><br><br>
<input type=&quot;button&quot; name=&quot;opn&quot; value=&quot;open a window&quot; onClick=&quot;subm()&quot;>
</form>
</BODY>
</HTML>
 
fayna,
when you open a new window, give it a name (&quot;newWin&quot; in my example) and then you just refer to that window by its name. for example, newWin.document.form_name.field_name.value

hth
 
Hi:

Thanks.. that puts me on the right track! sort of..

Is there another way to do it without writing the html..

The popup I am trying to populate is a form to add a new contact on the fly. The parent form is a form that a user will use to add a message to a database.

There are dropdowns on the page allowing the user to select a company, then it refreshes to list available contacts in another dropdown... if the contact does not exist.. I'd like to have the user click &quot;add contact&quot; to open the popup, populated with the company name and id, allow the user to enter the contact name, number, etc.. then submit to add the data to a table. After a conformation, the user will close the form, and the data will be written to the appropriate fields on the parent form and they can continue with their message entry..

Thanks! - AB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top