Código PHP:
function envia(url, id_form){
var formulario = document.getElementById(id_form);
var longform = formulario.elements.length;
var cadenaform = ""
var sepcampos
sepcampos = ""
for (var i=0; i <= formulario.elements.length-1;i++) {
cadenaform += sepcampos+formulario.elements[i].name+'='+encodeURI(formulario.elements[i].value);
sepcampos="&";
}
pagina_requerida.open("POST", url, true);
pagina_requerida.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=ISO-8859-1');
pagina_requerida.onreadystatechange = function () {
if ( pagina_requerida.readyState == 4) {
document.getElementById('contenedor').innerHTML = "Los datos han sido enviados correctamente";
}
}
pagina_requerida.send(cadenaform);
}
Código PHP:
<form name="form1" method="post" action="">
<br>
<div style="background-image: url(../Imagenes/fondito4.png); background-position:center top; background-repeat:no-repeat;">
<br><br>
<table width="267">
<caption align="top">
<span class="Estilo4"><img src="../Imagenes/nuevo_ad.png" width="335" height="50" border="0"></span>
</caption>
<tr>
<th align="right">Identificacion</th>
<td align="left"><input name="id_adm" type="text"></td>
</tr>
<tr>
<th align="right">Nombres</th>
<td align="left"><input name="nom_adm" size="40" type="text" onKeyUp="this.value=this.value.toUpperCase();"></td>
</tr>
<tr>
<th align="right">Direccion</th>
<td align="left"><input name="dir_adm" type="text" id="dir_acre"></td>
</tr>
<tr>
<th align="right">Telefono</th>
<td align="left"><input name="tel_adm" type="text" id="tel_acre"></td>
</tr>
<tr>
<th align="right">Cargo</th>
<td align="left"><select name="cargo" id="cargo">
<option value="0" selected="selected">-----------------</option>
<option>Rectora</option>
<option>Secretaria</option>
<option>Coordinadora</option>
<option>Auxiliar de Servicios</option>
</select></td>
</tr>
<tr>
<th colspan="2" scope="row">
<a class="enlace" href="#" onClick="envia('../dao/php_administrador/nuevo.php', 'form1');return false" ><img src="../Imagenes/botong.png" width="112" height="38" border="0"></a>
<a class="enlace" href="#" onClick="document.forms.form1.reset();return false"><img src="../Imagenes/cancelar.png" width="112" height="38" border="0"></a>
</th>
</tr>
</table>
<br>
</div>
</form></center>