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

To get value between the two windows?????

Status
Not open for further replies.

dat

Technical User
Oct 20, 2000
15
0
0
CA
I have an html page with a button,when click on it opens another html(different window) with some text .I want to get the value of button into a text of another html page.Is it possible pl someone help......

//one html form
one.html
<html>

<script language=javascript src=link.js>
</script>

<body>
<input type=&quot;button&quot; name=&quot;n1&quot; value=&quot;xyz&quot; onClick=&quot;openWindow(this)&quot;>
</body>
</html>

//this is link.js
function openWindow(a)
{
var x=window.open('two.html','newwindow' ,'height=300
width=300');
}

two.html
<html>
<body>
<input type='text' name='n2' value=&quot;&quot;>
</body>
</html>

this code opens new window with the text.I want the text to have a value xyz(button value of one.html) Is it possible???
 
Right what you need to do is to use the DOM (Document Object Model) and javascript. If your using frames I know that this will be the case. If you open a window in a frame which is higher up in the heirarchy then for the new page to access a field in a page above it (i.e. one which the link to the new page is in) try something like:
parent.window.document.IDOfButton.value
If you now add a ID field to the Button this may work
--------------------------------------------------

//one html form
one.html
<html>

<script language=javascript src=link.js>
</script>

<body>
<input type=&quot;button&quot; name=&quot;n1&quot; value=&quot;xyz&quot; ID=&quot;button1&quot; onClick=&quot;openWindow(this)&quot;>
</body>
</html>

//this is link.js
function openWindow(a)
{
var x=window.open('two.html','newwindow' ,'height=300
width=300');
}

two.html
<html>
<HEAD>

<body>
<input type='text' name='n2' value=&quot;parent.window.document.Button1.value&quot;>
</body>
</html>

--------------------------------------------------

Not 100% whether this will work but it may head you in the right direction. If it works email me back
Cheers
Dave
 
Hi Dave

Thank u so much for the reply,but I am not clear as to where to include this parent.window.document.IDOfButton.value.Without using this if I use the same code which u hv suggested then in the text field I am getting the value as parent.window.document.Button1.value instead of the actual value of the Button.Pl can u give me some more information

Thanks
dat
 
hiee!
>dat


well, a1defiant is right, but u have some other ways 2 pass variables between pages (may be it is not for your case, but it might help u in future):

opener.variable - where variable defined in opener

by location.search() - if u're interested, i can explain

thru window.name - when u're openin a new window - u can write not &quot;newwindow&quot; but &quot;newwindow_variable&quot; & then get it from there

hope this is usefull

best regards, vic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top