Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Sep 2006
    Posts
    216
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Targetting an iframe

    Hello,

    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.

    Code:
    <?php
    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>";
    	if(mysql_num_rows($result)) 
    	{ 
    	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>"; 
    	?>
    	</td>
    	</tr>
    </table>
    <div>
    
    
    <iframe src="statsystem.php" name="statsystem" height="450" width="200" class="iframe" FRAMEBORDER=0 scrolling="yes" ></iframe>
    Last edited by alex57; 12-19-2006 at 02:07 AM.

  • #2
    Senior Coder koyama's Avatar
    Join Date
    Dec 2006
    Location
    Copenhagen, Denmark
    Posts
    1,246
    Thanks
    1
    Thanked 5 Times in 5 Posts
    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?

  • #3
    New Coder
    Join Date
    Dec 2006
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts
    dont post your mysql login info to public boards 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
    http://demo.vegui.org - vegUI AJAX framework
    http://www.landsofkazram.com - browser based graphical MMORPG

  • #4
    Regular Coder
    Join Date
    Sep 2006
    Posts
    216
    Thanks
    9
    Thanked 0 Times in 0 Posts

    further info

    this is the content of the statsystem.php page. This page is the source of the iframe.

    Code:
    <?php
    $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:

    Code:
    <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.
    Last edited by alex57; 12-19-2006 at 02:08 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •