Mar
28
Маленький такой AJAX
02:39<html>
<head>
<title>JavaScript -> PHP -> Результат работы</title>
<script language="JavaScript" src=""></script>
<script language="JavaScript">
function loadinDiv(div_id){
document.scripts(0).src='java_s.php?text='+div_id.id;
}
</script>
</head>
<body>
<div id="main1"onclick=" loadinDiv(this)">Меню1</div>
<div id="submain1"></div>
<div id="main2"onclick=" loadinDiv(this)">Меню2</div>
<div id="submain2"></div>
</body>
</html>
//java_s.php
<?php
$script=<<<SCRIPT
var subdiv=document.all.sub%rep%;
if(subdiv.innerHTML==''){
subdiv.innerHTML='$text';
subdiv.style.display='';
}else{
subdiv.innerHTML='';
subdiv.style.display='none';
}
SCRIPT;
echo str_replace("%rep%",$text,$script);
?>