Cita:
Iniciado por carlosmbrizuela
La funcion cargocontenido() es una funcion js? que es ese 2 que le estas pasando?
Una de las maneras tb es usando Ajax.
la funcion cargacontenido si es JS y el 2 es un identificador ya que dentro de esa funcion tengo un switch, de todos modos aki te dejo la funcion:
Código PHP:
function cargaContenido(opc)
{
switch(opc)
{
case 1:
ajax=nuevoAjax();
a = document.getElementById('proyecto').value;
b = document.getElementById('nomb').value;
ajax.onreadystatechange = alertContents;
ajax.open('POST', "Guardar_Proyecto.php", true);
ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
ajax.send("proyecto="+a+"&nomb="+b);
Des_bloquear();
break;
case 2:
// I N I C I O
var valor=document.getElementById("capitulo").options[document.getElementById("capitulo").selectedIndex].value;
if(valor==0)
{
// Si el usuario eligio la opcion "Elige", no voy al servidor y pongo todo por defecto
combo=document.getElementById('partida');
combo.length=0;
var nuevaOpcion=document.createElement("option"); nuevaOpcion.value=0; nuevaOpcion.innerHTML="Seleccionar";
combo.appendChild(nuevaOpcion); combo.disabled=true;
}
else
{
ajax=nuevoAjax();
ajax.open("GET", "Partidas.php?capitulo="+valor, true);
ajax.onreadystatechange=function()
{
if (ajax.readyState==1)
{
// Mientras carga elimino la opcion "Elige pais" y pongo una que dice "Cargando"
combo=document.getElementById("partida");
combo.length=0;
var nuevaOpcion=document.createElement("option"); nuevaOpcion.value=0; nuevaOpcion.innerHTML="Cargando...";
combo.appendChild(nuevaOpcion); combo.disabled=true;
}
if (ajax.readyState==4)
{
document.getElementById("fila_2").innerHTML=ajax.responseText;
}
}
ajax.send(null);
}
break;
case 3:
indice2 = document.getElementById('partida').selectedIndex;
indice3 = document.getElementById('medida').selectedIndex;
b = document.getElementById('partida')[indice2].text;
c = document.getElementById('nombre').value;
d = document.getElementById('cantidad').value;
e = document.getElementById('medida')[indice3].text;
f = document.getElementById('precio').value;
g = document.getElementById('proyecto').value;
h = document.getElementById('justi').value;
i = document.getElementById('total').value;
if( b == "Seleccionar")
window.alert("Seleccionar partida");
else if( c == "" )
window.alert( "Introduzca el nombre del insumo" );
else if( d == "" )
window.alert( "Introduzca la cantidad de insumo" );
else if( e == "Seleccionar" )
window.alert( "Seleccione el tipo de medida del insumo" );
else if( f == "" )
window.alert( "Introduzca el precio del insumo" );
else
{
ajax.onreadystatechange = alertContents;
ajax.open('POST','Guardar_Insumo.php', true);
ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
ajax.send("proyecto="+g+"&capitulo="+a+"&partida="+b+"&nombre="+c+"&cantidad="+d+"&medida="+e+"&precio="+f+"&justi="+h+"&total="+i);
Limpiar();
}
break;
case 4:
ajax=nuevoAjax();
var valor=document.getElementById("partida").options[document.getElementById("partida").selectedIndex].value;
ajax.open("GET", "Desc_partida.php?partida="+valor, true);
ajax.onreadystatechange=function()
{
if (ajax.readyState==4)
{
if( ajax.status == 200 )
{
target = "fila_3";
document.getElementById(target).innerHTML = ajax.responseText;
document.getElementById("descri").dinnerHTML = ajax.responseText;
}
}
}
ajax.send(null);
break;
}
}