Click to See Complete Forum and Search --> : Passing or Getting
lutra
11-30-2003, 03:11 AM
I all,
sorry but I'm still an "0" with javascript and I hope to find some help here.
Scenario:
I have a form that calls a template that have an Iframe inside. I need to pass the variable from the form to the template (not a problem) and to the Iframe too.
OR
To let the iframe to get the variable from the parent frame.
Thanks in advance
-- GM --
Khalid Ali
11-30-2003, 08:23 AM
One very important thing to remember,if the template is an out of domain resource?
then you will not be able to directly communicate with its document object sing JavaScript.In this case you will only have the option of passing variable value via the URL and then parse it on the templage side.
If the template is being served by the server that is hosting your pages then you can just reference the iframe by
1. Its frame name
parent.frameName......
2. parent.frames[index]........
3. Or you can assing an id attribute to this frame then get reference like this
document.getElementById("frameId")
lutra
11-30-2003, 10:13 AM
Hi, thanks for the feedback. Everything is hosted on one server.
Ok what I'm actually trying to do is to define the source for the Iframe, including in the url the variable I need (from the form).
[my application server language is ColdFusion]
So,
in the form page I have
-------------------------
<head>
<script language="JavaScript" type="text/javascript">
function pesquisa(){
document.getElementById("fr_res");
fr_res.location.href='resultados.cfm?criteria=' + '#' + pes.criteria.value + '#';
}
</script>
</head>
...
...
...
<form action="pesquisa.php" method="post" name="pes">
<table width="53%" border="0" align="center">
<tr>
<td width="54%"><input type="text" name="criteria" size="40" >
</td>
<td width="46%"><div align="center">
<input name="submit" type="submit" value="Pesquisar" onclick="pesquisa()">
</div>
</td>
</tr>
</table>
</form>
-------------------------
Then, assuming the above correct (probably not), I don't how to refer the Iframe source in my template containing the Iframe:
-------------------------
...
...
<iframe id="fr_res" name="fr_res" frameborder="0" src="?" width="100%" height="300"></iframe>
...
...
-------------------------
Thanks in advance
-- Giovanni --
ray326
11-30-2003, 08:04 PM
document.getElementById("fr_res").src="yourURL";