我尝试了很多代码而且都无济于事。如果用户要单击(按钮)New Starter(/ button),我希望它在同一页面内回显文件new.php,如果用户然后选择辞职,那么它应该用resign.php替换new.php
<"new.php"><button>New Starter</button></a>
<"resign.php"><button>Resignation</button></a>
<"promo.php"><button>Promotion</button></a>
所以我们的想法是,它会在按钮点击同一页面时显示相关信息
这个php显示一个纯文本文件,回声没有问题,但将其合并到onclick或按钮内导致页面空白或相互显示相关文件
<?php echo file_get_contents('new.php'); ?>
<button on click echo $abc="new.php";}>New Starter</button>
<?php {echo $abc; } ?>
任何帮助或建议都会非常苛刻
答案 0 :(得分:2)
<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>
然后在身体
<div id="myDiv"><h2>Test</h2></div>
<button type="button" onclick="loadXMLDoc()">Test</button>