View Full Version : Targetting an iframe

12-19-2006, 12:23 AM

I have a drop down box. The values are read in using php and there is an onchange event which posts one of the drop down box values. I would like it to post the value to an iframe located on the same page. Is this possible?

My code is below, but it does not target the iframe properly, instead a new page is loaded and shows the value.

mysql_connect("localhost", "root", "") or die(mysql_error());

mysql_select_db("info") or die(mysql_error());

$query = "SELECT PremTeamName FROM premteams ORDER BY PremTeamName";

$result = mysql_query($query) or die(mysql_error());

echo "<form action='statsystem.php' method='post' target='statsystem'><select name='selection'>";
echo "<option size=30>Select</option>";
while($row = mysql_fetch_array($result))
echo "<option>" . $row['PremTeamName'] . "</option>";


else {
echo "<option>No Names Present</option>";
echo "</select><input type='submit' value='Submit'></form>";

<iframe src="statsystem.php" name="statsystem" height="450" width="200" class="iframe" FRAMEBORDER=0 scrolling="yes" ></iframe>

12-19-2006, 02:03 AM
Possibly, it is possible. Glancing on what you have shown us so far, this part looks fine, so the error must either lie in your script with the 'onchange'---or in the iframe itself.

Could you please show us some more?:)

12-19-2006, 02:40 AM
dont post your mysql login info to public boards :D even if no one knows the address of your server (or if its local only) posting passwords is always a bad thing.

As to your problem i concur with koyama, more info needed :)

12-19-2006, 03:06 AM
this is the content of the statsystem.php page. This page is the source of the iframe.

$title = $_POST['selection'];
echo $title;

very simple, was just trying to test that a value can be passed across.
Is there any way that the line of code reading:

<form action='statsystem.php' method='post' target='statsystem'>

could have an action pointing to the iframe? and not only to the statsystem.php page. I think is what is happening is on loading the 'shirtfin442' page the iframe source, 'statsystem.php', is being shown in its current state. When the drop down box changes and the submit button is pressed, it directs to the statsystem.php page and not statsystem.php within the iframe.