Getting Values From An Iframe In Javascript?

Ok, i am trying to do the following:

1) Once the page loads run the email() function
2) Delay getting values from Iframe (since it needs some time to load)
3) Get the "to" text value within the iframe form
4) Update the "to" value on the mainpage with the one from the iframe
5) Submit the form in the iframe


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>TEst</title>
<script language="javascript">
function email()
{
document.getElementById('test').src="http://www.example.com/useremail.php?id=34";
setTimeout("getvalues()",5000);
}
 
function getvalues()
{
var to=window.frames['test'].document.forms[0].to.value;
 
}
</script>
</head>
 
<body onload="email();">
 
<form name="mainpage" id="mainpage">
<input type="hidden" name="to" value="" /> 
</form>
 
<iframe id="test" src="about:blank"></iframe>
	
</body>
</html>
 
====================
useremail.php
====================
 
The form in useremail is this
<form method="POST">
<input name="from" size="30" maxlength="35" type="text">
<input name="to" size="30" maxlength="35" type="text">
<input name="subject" size="60" maxlength="105" type="text">
<input type="submit"/>

Open in new window

Blackwave003Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
Give the iframe a name. Look at the attached code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>blackWave1.html</title>
<script language="javascript">
function email()
{
document.getElementById('test').src="blackWave2.html";
setTimeout("getvalues()",5000);
}
 
function getvalues()
{
var to=window.frames['test'].document.forms[0].to.value;
 alert(to);
}
</script>
</head>
 
<body onload="email();">
 
<form name="mainpage" id="mainpage">
<input type="hidden" name="to" value="" /> 
</form>
 
<iframe id="test" name="test" src="about:blank"></iframe>
	
</body>
</html>
 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>blackWave2.html</title>
</head>
<body>
 
====================
useremail.php
====================
 
The form in useremail is this
<form method="POST">
<input name="from" size="30" maxlength="35" type="text">
<input name="to" size="30" maxlength="35" type="text" value="hi">
<input name="subject" size="60" maxlength="105" type="text">
<input type="submit"/>
 
</body>
</html>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Computer101Commented:
Forced accept.

Computer101
EE Admin
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.