Reputation: 437
I want to set the url of an iframe using PHP, my url is in that format : http://mysite.com/s/ where = numbers, I want to make a button that increase the number in the url of 1 and reload the iframe.
<html>
<head>
<meta charset="utf-8" />
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form class="topBorder">
<p>
<?php
$site = 6394100;
function NextSite($sites)
{
$sites += 1;
return 'http://mywebsite.com/s/' . $sites . '/';
}
?>
<a href="<?php echo NextSite($sites); ?>" target="frame"> Next </a>
</p>
<iframe name="frame" id="frame" src="http://mywebsite.com/s/" class="gagFrame"></iframe>
</form>
</body>
</html>
Upvotes: 0
Views: 108
Reputation: 3374
Well you can take help of a simple JS function for this. See the modified code below. I have not tested it but you should get the idea of doing it.
EDIT:
You need to get it done the ajax way. Put your php function in a file say loadurl.php:
<?php
$site = 6394100;
$sites += 1;
echo 'http://mywebsite.com/s/' . $sites . '/';
?>
Now in your html code do as follows:
<html>
<head>
<meta charset="utf-8" />
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form class="topBorder">
<script type="text/javascript">
function loadURL()
{
$.get('pathToloadurl.php',success(data)
{
window.frames[siteFrame].location =data;
});
}
</script>
<button type="button" onClick="loadURL()">Next</button>
<iframe name="siteFrame" id="frame" src="http://mywebsite.com/s/" class="gagFrame"></iframe>
</form>
Upvotes: 1