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!

How to link HTML to JavaScript to again HTML page

Status
Not open for further replies.

dat

Technical User
Oct 20, 2000
15
0
0
CA
I am trying to do the following.I have a HTML page in which I have a button storing email address,when I click on that button I should get a HTML page with same email address store in a text.How should I do it.My scirpt is----

<html>
<script language=javascript>
function onClick(a)
{

var w=window.document.form[0].n1.value
window.write(w);
}
<body>

<table bgcolor=megenta align=center width=100% cellspacing=2 cellpadding=2>

<td align=left><input type=button name= n1 value=ascdef@hotmail.com onClick=&quot;onClick(this)&quot;>
</body>
</html>


When I click on the button I sh get
Email Address: email address sh come here and the
Submit button
 
Your function &quot;onClick&quot; may or may not confuse the JavaScript interpreter, come up with another, more descriptive, name for your function like &quot;displayEmail().&quot;

write() is not a method of the window object, but rather of the document object, so you want to say &quot;document.write();&quot;

You should also use a <form> tag before you start entering elements, some browsers won't display any of your form elements without leading and trailing <form></form> tags.

Hope this helps,
johnny
 
Thanks Johnny for u'r reply.I think i was not very clear and made mistake while typing.Let me be more clear.

I have an html page with a button(which contains email address),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.

//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(no value in it).I want the text to have a value xyz ie my email address(button value of one.html) Is it possible???


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top