Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

iframes, coldfusion, and javascript

Guest
Mar 04, 2009 Mar 04, 2009
hello everyone,

I am new with iframes. Currently I am creating an iframe within an existing form. The main form has couple of checboxes, and also the iframe has couple of checkboxes. I want to pass the values of iframe checkboxes to another page when a submit button is clicked. The submit button is present in the main page. Is there a way to do this. I was trying to use a hidden text box in the main page which will get populated with the iframe checkbox value, but this does not seem to be working.

Can anyone suggest anyother way of doing? my current code is as follows

<html>
<script language="javascript" type="text/javascript">

function checKer(inputID) // where inputID = checkbox
{
var x = document.ScannedSearch.elements[inputID];
var ifOb =window.frames("iframecat");
var y = ifOb.document.forms["SelectCategories"].elements[inputID];
if(y.checked == true)
{
alert('Is checked and has a value of y = ' + y.value);
}
else
{
alert('Is not checked');
}
}
</script>
<body onLoad="">
<form name="ScannedSearch" method="post" action="filler1.cfm">
<input type="text" name="iframecategories" value="">
IFrame3: <input type="checkbox" id="testcheck" value="IFrame3" onClick="checKer('testcheck')";/>
IFrame4: <input type="checkbox" name="try2" value="IFrame4" />


<iframe id="iframecat" src="filler.cfm">


</iframe>
<input type="submit" name="submit" value="Go"/>

<br>
<br>
<br>
</form>
</body>
</html>

filler.cfm

<html>


<form action="filler1.cfm" name="SelectCategories" method="post">
IFrame1: <input type="checkbox" name="IFrame1" id="IFrame1" onclick="checKer('IFrame1');"/>
IFrame2: <input type="checkbox" name="IFrame2" id="IFrame2" onclick="checKer('IFrame2');"/>

</form>
</html>

Thanks
4.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 04, 2009 Mar 04, 2009
Why don't you put those checkboxes into the existing form and process them in the action page? It seems a lot simpler than what you are attempting.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 04, 2009 Mar 04, 2009
well these checkboxes are populated dynamically...it would be great if anyone can give some suggestions....

i am not able to get the checkboxes whatever I do....
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 04, 2009 Mar 04, 2009
LATEST
Ok, I got it working now...below is the right code... iframes.cfm <html>
<script language="javascript" type="text/javascript">

function checKer(inputid) // where inputID = checkbox
{


var frame = window.frames['iframecat'];
var elem = frame.document.SelegetElementById(inputid).value;
//var tex = document.ScannedSearch.
alert(elem);
}

function checkifSelect()
{

var frame = window.frames['iframecat'];
var elem = frame.document.SelectCategories.IFrame2;
if(frame.document.SelectCategories.IFrame2.checked == true)
{
document.ScannedSearch.iframecategories.value = elem.value;
}
else
{
document.ScannedSearch.iframecategories.value = '';

}
}
</script>
<body>
<form name="ScannedSearch" method="post" action="filler1.cfm">
<input type="text" name="iframecategories" value="">
IFrame3: <input type="checkbox" id="testcheck" value="IFrame3"/>
IFrame4: <input type="checkbox" name="try2" value="IFrame4" />


<iframe id="iframecat" src="filler.cfm">


</iframe>
<input type="submit" name="submit" value="Go" onClick="checkifSelect()"/>

<br>
<br>
<br>
</form>
</body>
</html>

filler.cfm
<html>


<form action="filler1.cfm" name="SelectCategories" method="post">
IFrame1: <input type="checkbox" name="IFrame1" value="hello"/>
IFrame2: <input type="checkbox" name="IFrame2" value="Hey" />

</form>
</html>

filler1.cfm
<cfif isdefined("form.testcheck")>
<cfoutput>You selected: #form.iframecategories#</cfoutput>
<cfelseif isdefined("form.try2")>
<cfoutput>You selected: #form.try2#</cfoutput>
<cfelseif isdefined("form.iframecategories") and form.iframecategories eq 'Hey'>
<cfoutput>Yes, this is the value of the iframe checkbox</cfoutput>
<cfelse>
<cfoutput>Nothing</cfoutput>
</cfif>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources