Page 1 of 1
Passing value from iframe to parent[solved]
Posted: Tue Apr 24, 2007 7:16 am
by kpraman
How to pass value from iframe to parent?
Posted: Tue Apr 24, 2007 7:21 am
by CoderGoblin
From
YourHtmlSourceIf you have multiple iframes on the same page you can have them interacting, by sending commands between them, just like normal frames...
So simply treat the Iframe handling as you would any other frame... If you are unsure of the frame method you can look it up by following the link provided.
Hope that helps...
Posted: Tue Apr 24, 2007 7:33 am
by kpraman
I don't have multiple iframes, I have a form in that form i have put an iframe. In the iframe, i am displaying some filenames along with radio buttons. In the form there is also a textbox. When i click on the radiobutton that value should appear in the textbox.
Posted: Tue Apr 24, 2007 7:39 am
by feyd
Why are you using an iframe and more importantly, what does this problem have to do with PHP?
Posted: Tue Apr 24, 2007 7:59 am
by kpraman
I am using since there is no space to display all the files(images).
In the parent i have a text box, when i click on the images or radiobutton(which i display along with the image), that value should appear in the text so there is no need to type. Once it is done the form will be submitted.
Posted: Tue Apr 24, 2007 8:01 am
by CoderGoblin
You don't need multiple Iframes but the quote was from the link so I didn't change it. The point being made is that generally Iframes act as normal frames when it comes to moving information between them, either through javascript or forms.
Saying that from your updated information I would have to question why you are using an Iframe. It appears that anything you are doing could be done with HTML and CSS (look up CSS overflow if you need scrolling). To update things on the fly (on radio button change) you would need to insert some javascript as the radio button "onchange" event. The only question is then what happens if someone doesn't have javascript enabled ?
Iframes do have uses but in my opinion they are rarely needed as there are better/simpler alternatives.
Posted: Tue Apr 24, 2007 8:18 am
by kpraman
I almost solved it, why i am getting the error everytime i click on radio button.
error:filename undefined (i.e what ever the file name is)
Code: Select all
foreach($filename as $filenames)
{
echo "<input type=radio name=radio onclick=callme($filenames)> $filenames";
echo "<br>";
}
?>
Code: Select all
<script language="JavaScript">
function callme(filenames)
{
parent.document.form1.imagename.value ="check";
}
</script>
Posted: Tue Apr 24, 2007 8:32 am
by CoderGoblin
Without seeing the rest of your code...
Code: Select all
foreach($filenames as $filename)
{
echo "<input type=\"radio\" name=\"radio\" onclick=\"callme({$filename})\"> {$filename}<br />";
}
shouldn't the loop be of filenames with the values being $filename rather than the other way around ?