|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
child window link values
Hi.
![]() I need to have a link in a child window, to set the value of a input[text] in the parent window. how do i do this ?? - Pheifel |
|
#2
|
||||
|
||||
|
I made up a working example of this.
I love Javascript DOM! =) This first page would be your parent window. It contains a form with a text box. Code:
<html>
<head>
<title>Page</title>
</head>
<body>
<h1>Form with Popup Example</h1>
<p><a href="#" onclick="javascript:window.open('pop.htm','mypop','width=15 0,height=210');">Popup Window</a></p>
<form>
<input type="text" name="input1" /><br/>
<input type="submit" />
</form>
</body>
</html>
This second page would be your popup window. I made it have a link which sets the text directly. You may want the text to come from a Form element in the popup window, but I assume you are capable of doing that yourself. I've named this pop.htm, if yuo name it something different, be sure to change the window.open command in the parent window. Code:
<html>
<head>
<title>Page</title>
<script>
function setParentText(str) {
window.opener.document.bgColor = "beige";
window.opener.document.forms[0].elements[0].value = str + '';
window.opener.restart();
//window.close();
}
</script>
</head>
<body>
<h1>Popup Form</h1>
<a href="#" onclick="javascript:setParentText('Hello world');">Click here to set the text</a>
</body>
</html>
|
|
#3
|
||||
|
||||
|
vBulletin has put a weird space in this line:
javascript:window.open('pop.htm','mypop','width=15 0,height=210'); on my parent window... that should read 150, without the spaces. |
|
#4
|
|||
|
|||
|
thnx a bunch
thats nice it works like a charm ![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > child window link values |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|