salva questo codice come
laod.js
codice:
var req;
function loadXMLDoc(key) {
var url="prova.php?tipo="+key;
getObject("campi").innerHTML = 'Attendere Prego...';
try { req = new ActiveXObject("Msxml2.XMLHTTP"); }
catch(e) {
try { req = new ActiveXObject("Microsoft.XMLHTTP"); }
catch(oc) { req = null; }
}
if (!req && typeof XMLHttpRequest != "undefined") { req = new
XMLHttpRequest(); }
if (req != null) {
req.onreadystatechange = processChange;
req.open("GET", url, true);
req.send(null);
}
}
function processChange() {
if (req.readyState == 4 && req.status == 200) {
getObject("zona").innerHTML = req.responseText;
document.res_request.state.focus();
}
}
function getObject(name) {
var ns4 = (document.layers) ? true : false;
var w3c = (document.getElementById) ? true : false;
var ie4 = (document.all) ? true : false;
if (ns4) return eval('document.' + name);
if (w3c) return document.getElementById(name);
if (ie4) return eval('document.all.' + name);
return false;
}
poi crei una pagina chiamata prova.php
Codice PHP:
if($_GET['tipo']=="azienda"){
echo "<input type=\"text\" name=\"nome\" />";
.....
......
.....
//tutti gli input che vuoi stampare per azienda
}
if($_GET['tipo']=="privato"){
echo "......";
//tutti gli input che vuoi stampare per privato
}
poi includi lo script js nell sito
codice:
<script type="text/javascript" src="load.js"></script>
e i checkbox che fai dovranno essere così
codice:
<input type="checkbox" name="tipo" value="privato" onchange="loadXMLDoc(this.value);">Privato
<input type="checkbox" name="tipo" value="azienda" onchange="loadXMLDoc(this.value);">Azienda
e nel form dove vuoi che escano gli input fai
codice:
<form ....... >
<div id="campi"></div>
</form>
ti ho dato tutto il necessario...buon lavoro 