First the simple post script:
Code: Select all
xmlhttp.open("POST",posturl,false);
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
xmlhttp.send(input);
var accountData;
accountData = xmlhttp.responseText;
var main, account;
main = document.getElementById('table23');
if (main) {
account = document.createElement('account');
account.innerHTML = accountData;
main.parentNode.insertBefore(account, main.nextSibling);
}Now for the PHP.
Code: Select all
$output ="<script type='text/javascript' language='javascript'>
function accountToggle(id)
{
if(id == 'accountchart')
{
document.getElementById('accountchart').style.display = '';
document.getElementById('accountdocs').style.display = 'none';
document.getElementById('accountAdmin').style.display = 'none';
}
if(id == 'accountdocs')
{
document.getElementById('accountchart').style.display = 'none';
document.getElementById('accountdocs').style.display = '';
document.getElementById('accountAdmin').style.display = 'none';
}
if(id == 'accountAdmin')
{
document.getElementById('accountchart').style.display = 'none';
document.getElementById('accountdocs').style.display = 'none';
document.getElementById('accountAdmin').style.display = '';
}
}
</script>
<table id='account'>
<tr>
<td onClick=accountToggle('accountchart') Style='cursor:hand'>chart</td>
<td onClick=accountToggle('accountdocs') Style='cursor:hand'>docs</td>
<td onClick=accountToggle('accountAdmin') Style='cursor:hand'>Admin</td>
</tr>
<tr><td colspan='3'>
<table id='accountchart'>
<tr><td>chart</td></tr>
</table>
</td></tr>
<tr><td colspan='3'>
<table id='accountdocs' bgcolor>
<tr><td>docs</td></tr>
</table>
</td></tr>
<tr><td colspan='3'>
<table id='accountAdmin'>
<tr><td>Admin</td></tr>
</table>
</td></tr>
</table>";
print_r("$output");