Passing value from iframe to parent[solved]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

Passing value from iframe to parent[solved]

Post by kpraman »

How to pass value from iframe to parent?
Last edited by kpraman on Wed Apr 25, 2007 1:17 am, edited 1 time in total.
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

From YourHtmlSource
If 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...
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Why are you using an iframe and more importantly, what does this problem have to do with PHP?
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

Post 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.
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post 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.
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

Post 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>
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post 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 ?
Post Reply