Hello,
I found a script that refreshes a div tag but it only works half way. I have a php if statement in the middle of the script and based on the if decision it should display the appropriate information.
if no click display " button not pressed"
else
echo random number
the first part works but not the sec. part.
any ideas as to how i can fix this.?
<html>
<head>
<meta charset="ISO-8859-1">
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function() {
$('#btn_click').on('click', function() {
var url = 'refreshDiv.php';
$('#div1-wrapper').load(url + ' #div1');
});
});
</script>
</head>
<body>
<?php echo rand(10,1000); // test outside the div container?>
<div id="div1-wrapper">
<div id="div1" style="border:solid 2px red; width: 200px;">
<form name="form1" method="POST">
<?php
if(empty($_POST["btn_click"]))
{ echo 'button not pressed'; }
else
{ echo rand(10,1000); }
?>
</div>
</div>
<button type="button" id="btn_click" /> click me! </button>
</form>
</body>
</html>