The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Web Design
> JavaScript Development
|
function for onclick iframe value change
Discuss function for onclick iframe value change in the JavaScript Development forum on Dev Shed. function for onclick iframe value change JavaScript Development forum discussing JavaScript and DHTML, AJAX, and issues such as coding cross-browser JavaScript.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

December 29th, 2004, 09:42 AM
|
 |
Contributing User
|
|
Join Date: Oct 2003
Location: Rio de Janeiro, Brazil
Posts: 447

Time spent in forums: 2 Days 14 h 17 m 46 sec
Reputation Power: 10
|
|
|
function for onclick iframe value change
Someone help me out.
I have 3 Iframes I only want to play with 2.
1) One has links for others to click on :
//Iframe 1
<a href="javascript:click(email@email.com)">email@email.com</a>
2) The other Iframe will receive the value on hidden form and non-hidden form:
//Iframe 2 name="envia" id="envia"
<form method="post" name="frm2" action="">
<input type="text" name="email" value="">
</form>
Could someone make a working function please.
Here´s what I got on Iframe 1
<script language="javascript">
function click(email){
window.frames['envia'].frm2.email.value = 'iframe_page1.html';
alert('ok');
}
</script>
__________________
Help my country and sign the petition in favor of OS software. See the Petition
Quote: | Linux is like sex, it's better when it's free! |
|

December 29th, 2004, 01:02 PM
|
 |
4:04 Time Not Found
|
|
Join Date: Jan 2004
Location: Northern Virginia
|
|
I would like to help, but I don't understand what you are trying to do. You laid your code out, but it is unclear as to what the code is supposed to do.
For future reference, please use CODE tags:
__________________
I am so smart, I am so smart, S.M.R.T ... I mean S.M.A.R.T.
Stop Using Pop-Ups
|

December 29th, 2004, 07:14 PM
|
 |
Contributing User
|
|
Join Date: Oct 2003
Location: Rio de Janeiro, Brazil
Posts: 447

Time spent in forums: 2 Days 14 h 17 m 46 sec
Reputation Power: 10
|
|
Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>whatever</title>
</head>
<body>
<iframe width="300" height="400" src="?pagina=mensagens"></iframe>
<iframe width="100" height="400" src="?pagina=online" frameborder="0"></iframe><br>
<iframe width="400" height="250" id="envia" name="envia" src="?pagina=envia" frameborder="0" scrolling="no"></iframe>
</body>
</html>
I´m calling a link from the "online" frame
Code:
<html>
<head>
<script language="javascript">
function usuario(email){
window.frames['envia'].frm2.email.value = 'iframe_page1.html';
alert('ok');
}
</script>
<META HTTP-EQUIV=Refresh CONTENT="1; URL=<?=$url?>">
</head>
<body>
<a href="javascript:click(email@email.com)">email@email.com</a>
</body>
</html>
And want it executed and values to be shown on the email input inside the iframe envia
Code:
<form method="post" name="frm2" action="">
<input type="text" name="email" value="">
</form>
|

December 29th, 2004, 10:23 PM
|
 |
4:04 Time Not Found
|
|
Join Date: Jan 2004
Location: Northern Virginia
|
|
Cool .. got it!
Okay, you're currently in the iframe with the src of "?pagina=online", as a side note you should probably give it a name, for consistancy.
From that iFrame, you can make a call to the "envia" iFrame with:
Code:
var YourValue = "I like JavaScript";
parent.envia.document.frm2.email.value = YourValue;
Of course you can set Your Value to whatever you want! If you need more, feel free to ask.
|

December 29th, 2004, 10:30 PM
|
|
Contributing User
|
|
Join Date: Nov 2004
Location: USA MI
Posts: 40
Time spent in forums: < 1 sec
Reputation Power: 9
|
|
If I am readin this correctly you are asking about passing a varible between two frames?
well if that is the case then here it is:
iframeContainer.htm - contains both frames
Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<P><IFRAME name="Action" src="ActionPage.htm">
</IFRAME></P>
<P><IFRAME name="Target" src="TargetPage.htm">
</IFRAME></P>
</body>
</html>
ActionPage.htm - contains action to send email
Code:
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
<TITLE>ActionPage</TITLE>
<SCRIPT>
function passEmail(em)
{
top.frames['Target'].document.frm2.email.value = em;
alert(em)
}
</SCRIPT>
</HEAD>
<BODY>
<a href="javascript:passEmail('email@email.com')">email@email.com</a>
</BODY>
</HTML>
TargetPage.htm - cintains form to receive email
Code:
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
<TITLE></TITLE>
</HEAD>
<BODY>
<form method="post" name="frm2" action="">
<input type="text" name="email" value="">
email shows here</form>
</BODY>
</HTML>
here is a demo
Hope this helps!
Mike
4thorder(TM) Code Snippets and Full Scripts
|

December 29th, 2004, 10:32 PM
|
|
Contributing User
|
|
Join Date: Nov 2004
Location: USA MI
Posts: 40
Time spent in forums: < 1 sec
Reputation Power: 9
|
|
|
opps sorry vbrtrmn
hit send before I saw your response
Mike
|

December 29th, 2004, 10:36 PM
|
 |
4:04 Time Not Found
|
|
Join Date: Jan 2004
Location: Northern Virginia
|
|
Quote: | Originally Posted by 4thorder hit send before I saw your response
Mike |
No problem! I'm sure he'll be happy with any help he can get  I'm glad to see others trying to help people out!
Thanks!
|

December 30th, 2004, 05:20 AM
|
 |
Contributing User
|
|
Join Date: Oct 2003
Location: Rio de Janeiro, Brazil
Posts: 447

Time spent in forums: 2 Days 14 h 17 m 46 sec
Reputation Power: 10
|
|
First thanks to vbrtrmn for his great effort on solving this, and pointing out that it was a messy explanation.
Second thanks to 4thorder for making a working example for me so I can have a "base" solution for this. (great job)
My problem is now solved thanks to you guys, Dev Shed and god.
Peace
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|