Posts Tagged Type Button

Accessing other frame data

In your main page you have an iframe. The iframe code is:

<input type=”text” value=”andy” name=”myname”>

To access the data from that iframe the syntax will be :

Formname.document.getElementsByName.(‘contaolname’)[0].value

So the code for the main file is:

<script>
function getvalue()
{
alert(frame1.document.getElementsByName(‘myname’)[0].value);
}
</script>
<iframe src=”form.php” name=”frame1″></iframe>

<input type=”button” value=”Get value” onclick=”getvalue()”>

, , , , , , ,

No Comments

jQuery reload page

When you load a page using require PHP function, there is time when you want to reload the page in require PHP function again. You can do this by using the require in a div. Then load the page again using jQuery load function.

Here’s the code in the main page:

<html>
<head>
<script type=”text/javascript” src=”jquery.js”></script>
<script type=”text/javascript”>
function  reload()
{
$(“#page”).load(“page.php?value=test”);
}
</script>
</head>
<body>
<div id=”page”>
<?php
require(“page.php”);
?></div>
<br>
<input type=button value=”Click to reload page.php” onclick=”reload();”>
</body>
</html>

And the function in page.php:

<?php
echo “Test value = ” . $_GET['value'];
?>

, , , , , , , , , , , , , ,

No Comments