Reputation: 21
I have tried numerous codes and all without avail. If the user was to click (button)New Starter (/button) I would like it to echo the file new.php within the same page and if the user was then to select resignation it should then replace new.php with resign.php
<"new.php"><button>New Starter</button></a>
<"resign.php"><button>Resignation</button></a>
<"promo.php"><button>Promotion</button></a>
So the idea is that it displays relevant information upon the button click on the same page
This php displays a text only file and echos no problem but incorporating it into onclick or within the button is causing the page to go blank or show the related file upon each other
<?php echo file_get_contents('new.php'); ?>
<button on click echo $abc="new.php";}>New Starter</button>
<?php {echo $abc; } ?>
Any help or advice would be greatly apreciated
Upvotes: 0
Views: 387
Reputation: 21
<head><script>
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","new.php",true);
xmlhttp.send();
}
</script>
</head>
Then in the body
<div id="myDiv"><h2>Test</h2></div>
<button type="button" onclick="loadXMLDoc()">Test</button>
Upvotes: 2