Foros del Web » Programando para Internet » Javascript »

Mantención de datos

Estas en el tema de Mantención de datos en el foro de Javascript en Foros del Web. Amigos: Tengo una página con 4 combos relacionados (el 1 con el 2, el 2 con el 3 y el 3 con el 4), también ...
  #1 (permalink)  
Antiguo 29/11/2004, 15:51
 
Fecha de Ingreso: julio-2004
Mensajes: 30
Antigüedad: 19 años, 9 meses
Puntos: 0
Mantención de datos

Amigos:

Tengo una página con 4 combos relacionados (el 1 con el 2, el 2 con el 3 y el 3 con el 4), también tengo otros datos que debo grabar. Debajo de este ingresador tengo un despliegue paginado.

Mi pregunta es ¿cómo cargar los combos inicialmente con el último valor ingresado (es el primer registro desplegado)? y ¿cómo permitir al usuario que, seleccionando una fila cualquiera se traspase los valores al ingresador?

Atte.
Fernando
  #2 (permalink)  
Antiguo 16/12/2004, 08:36
 
Fecha de Ingreso: julio-2004
Mensajes: 30
Antigüedad: 19 años, 9 meses
Puntos: 0
Alguien me puede ayudar

he tenido respuesta para esta consulta y me urge solucionar el problema.

Quedaré así si no lo resuelvo por una .

Gracias
  #3 (permalink)  
Antiguo 16/12/2004, 18:01
Avatar de baklao  
Fecha de Ingreso: noviembre-2004
Ubicación: Santa Ana - Isla de Margarita
Mensajes: 482
Antigüedad: 19 años, 5 meses
Puntos: 0
Creo que pude entenderte. prueba este codigo a ver si te sirve.


Código HTML:
<Script>
function muni() {
var p2;
p=document.registro.estado[document.registro.estado.selectedIndex].value;
p2 = reemplazarGuion(document.registro.estado[document.registro.estado.selectedIndex].value);
document.registro.estado[document.registro.estado.selectedIndex].value = p2;
var pais_1=new Array("","1")

var paisstnames_1=new Array("","Libertador (Caracas)")

var pais_2=new Array("","2","3","4","5","6","7","8","9")
var paisstnames_2=new Array("","Atures","Autana","Atabapo","Alto Orinoco","Guainía","Manapiare","Puerto Ayacucho","Río Negro")

var pais_3=new Array("","10","11","12","13","14","15","16","17","18","19","20","21")
var paisstnames_3=new Array("","Anaco","Aragua de Barcelona","Barcelona","Cantaura","Clarines","El Tigre","Pariaguán","Píritu","Puerto La Cruz","San Tomé","Santa Rosa","Soledad")

var pais_4=new Array("","22","23","24","25","26","27","28")
var paisstnames_4=new Array("","Achaguas","Biruaca","Muñoz","Páez","Pedro Camejo","Rómulo Gallegos","San Fernando")

var pais_5=new Array("","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46")
var paisstnames_5=new Array("","Bolívar (San Mateo)","Camatagua","Cagua","El Consejo","El Limón","La Victoria","Las Tejerías","La Colonia Tovar","Maracay","Ocumare de la Costa","Palo Negro","San Casimiro","San Sebastián","Santa Rita","Santa Cruz","Turmero","Urdaneta","Zamora")

var pais_6=new Array("","47","48","49","50","51","52","53","54","55","56","57","58")
var paisstnames_6=new Array("","Arismendi","Barinas","Barinitas","Barrancas","Ciudad Bolivia","Ciudad de Nutrias","El Canton","Libertad","Obispos","Santa Bárbara","Socopo","Sabaneta")

var pais_7=new Array("","59","60","61","62","63","64","65","66","67","68","69")
var paisstnames_7=new Array("","Ciudad Guayana","Caicara del Orinoco","El Callao","Santa Elena de Uairén","Ciudad Bolívar","El Palmar","Upata","Ciudad Piar","Guasipati","Tumeremo","Maripa")

var pais_8=new Array("","70","71","72","73","74","75","76","77","78","79","80","81","82","83")
var paisstnames_8=new Array("","Bejuma","Guigue","Mariara","Guacara","Morón","Tocuyito","Los Guayos","Miranda","Montalbán","Naguanagua","Puerto Cabello","San Diego","San Joaquín","Valencia")

var pais_9=new Array("","84","85","86","87")
var paisstnames_9=new Array("","Curiapo","Pedernales","Sierra Imataca","Tucupita")

var pais_10=new Array("","88")
var paisstnames_10=new Array("","Vacio")

//"89","90","91","92","93","94","95","96","97"

//var pais_2=new Array("","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","22","23","24","25")
//,"Cojedes","Delta Amacuro","Falcon","Guarico","Lara","Merida","Miranda","Monagas","Nueva Esparta","Portuguesa","Sucre","Tachira","Trujillo","Yaracuy","Zulia","resto")

for (xi=24;xi<=256;xi++)
   {
	eval ("pais_" + xi + "=new Array('')")
	eval ("paisstnames_" + xi + " =new Array('')")
   }
      seleccion=eval("pais_"+p);
      seleccionNames=eval("paisstnames_"+p);
      cuantos_add=seleccion.length;
      document.registro.State.length=cuantos_add;
      for(i=0;i<cuantos_add;i++)
       {
         document.registro.State.options[i].value=seleccion[i];
         document.registro.State.options[i].text=seleccionNames[i];
         if (seleccion[i]=="<!-- STATEID -->") 
         {
          document.registro.State.options[i].selected = true;
         }
       }
}

</SCRIPT>
<form name=registro>
<SELECT name=estado onchange=muni() style="border: 1px solid #000080; " size="1"> <OPTION 
        value=cero selected>Seleccione Municipio</OPTION>
<option value="7">Antolin del Campo</option>
<option value="8">Arismendi</option>
<option value="2">Díaz</option>
<option value="9">García</option>
<option value="4">Gomez</option>
<option value="6">Maneiro</option>
<option value="1">Marcano</option>
<option value="5">Mariño</option>
<option value="10">Peninsula de Macanao</option>
<option value="3">Tubores</option>
<option value="11">Villalba</option>
</SELECT>

<select size="1" name="State" style="border: 1px solid #000080; " > </select>

</form> 
Salu2. Espero q te sirva pero de todas maneras avizame si te sirvio.

Suerte.
__________________
Atte. Mohamed :aplauso:
  #4 (permalink)  
Antiguo 17/12/2004, 06:13
 
Fecha de Ingreso: julio-2004
Mensajes: 30
Antigüedad: 19 años, 9 meses
Puntos: 0
Baklao:

El código que tengo es:
<%
Call Main()

Sub Main()
If Request.Form("Submit") <> "" Then
Session("cVar2") = Request.Form("lstComponente")
Session("cVar3") = Request.Form("lstSubComponente")
Session("cVar4") = Request.Form("lstTarea")
Session("cVar5") = Request.Form("strWorkProduct")
Session("cVar6") = Request.Form("strComentarios")
Session("cVar7") = Request.Form("strFecha")
Session("cVar8") = Request.Form("strCompleta")
Session("cVar9") = Request.Form("strHora")
Session("cVar10") = Request.Form("strMinutos")
Response.Redirect "Grabar.asp"
Exit Sub
End If

Dim oConn
Dim strSQL

%>
<!-- #include file="Include/Base.inc" -->
<%

Dim rsComponente
Dim rsSubComponente
Dim rsTarea

Dim strComponente
Dim strSubComponente
Dim strTarea

Set rsComponente = Server.CreateObject("ADODB.Recordset")
Set rsSubComponente = Server.CreateObject("ADODB.Recordset")
Set rsTarea = Server.CreateObject("ADODB.Recordset")

strSQL = "SELECT ID_Componente, Nombre FROM Componente WHERE Activo = 'S'"
Set rsComponente = oConn.Execute(strSQL)

strComponente = Request.Form("lstComponente")
If strComponente = "" Then
If Not rsComponente.EOF Then
strComponente = rsComponente("ID_Componente")
End If
End If
If strComponente <> "" Then
strSQL = "SELECT ID_Subcomponente, Nombre FROM SubComponente WHERE ID_Componente=" & strComponente & " AND Activo = 'S'"
Set rsSubComponente = oConn.Execute(strSQL)
strSubComponente = Request.Form("lstSubComponente")
If strSubComponente = "" Or Request.Form("hid_Componente_Changed") = "True" Then
If Not rsSubComponente.EOF Then
strSubComponente = rsSubComponente("ID_SubComponente")
End If
End If
strSQL = "SELECT ID_Modulo, Nombre FROM Modulo WHERE ID_SubComponente=" & strSubComponente & " AND Activo = 'S'"
Set rsTarea = oConn.Execute(strSQL)
End If
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft FrontPage 4.0">

</HEAD>
<BODY>

<FORM NAME=frmPaginar2 ACTION="Paginar.asp" METHOD="post" ID="frmPaginar2">


<INPUT TYPE=HIDDEN NAME=hid_Componente_Changed>
<INPUT TYPE=HIDDEN NAME=hid_SubComponente_Changed>

<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="10%"></td>
<td width="10%">&nbsp;</td>
<%
Response.Write "<td width='60%' colspan='6'><H2> <p align='center'>"
Response.Write cNombre
Response.Write "</p></H2></td>"
%>
<td width="10%">&nbsp;</td>
<td width="10%">&nbsp;</td>
</tr>
</table>
<table border="0" width="100%">
<tr>
<td width="12%"><font face="Verdana" size="1"><b>Nivel 1:</b></font></td>
<td width="88%"><font face="Verdana" size="1"><SELECT id=lstComponente name=lstComponente onchange="ChangeComponente()" >
<%
If Not rsComponente.EOF Then
Do While Not rsComponente.EOF
strComponente = rsComponente("Nombre")
If cInt(rsComponente("ID_Componente")) = cInt(Request.Form("lstComponente")) Then
%>
<OPTION Value="<%=rsComponente("ID_Componente")%>" SELECTED> <%=strComponente%></OPTION>
<%
Else
%>
<OPTION Value="<%=rsComponente("ID_Componente")%>" > <%=strComponente%></OPTION>
<%
End If
rsComponente.MoveNext
Loop
End If
rsComponente.MoveFirst
%>
</SELECT></font></td>
</tr>
<tr>
<td width="12%"><font face="Verdana" size="1"><b>Nivel 2:</b></font></td>
<td width="88%"><font face="Verdana" size="1"><SELECT id=lstSubComponente name=lstSubComponente onchange="ChangeSubComponente()" >
<%
If Not rsSubComponente.EOF Then
Do While Not rsSubComponente.EOF
strSubComponente = rsSubComponente("Nombre")
response.write "+" &rsSubComponente("ID_SubComponente") & "+ --- +" & Request.Form("lstSubComponente") & "+"
If rsSubComponente("ID_SubComponente") = CDbl(Request.Form("lstSubComponente")) Then
%>
<OPTION Value="<%=rsSubComponente("ID_SubComponente")%>" SELECTED> <%=strSubComponente%></OPTION>
<%
Else
%>
<OPTION Value="<%=rsSubComponente("ID_SubComponente")%>" > <%=strSubComponente%></OPTION>
<%
End If
rsSubComponente.MoveNext
Loop
End If
rsSubComponente.MoveFirst
%>
</SELECT></font></td>
</tr>
<tr>
<td width="12%"><font face="Verdana" size="1"><b>Tarea</b></font></td>
<td width="88%"><font face="Verdana" size="1"><SELECT id=lstTarea name=lstTarea >
<OPTION Value="0">Escoja una tarea</OPTION>
<%
If Not rsTarea.EOF Then
Do While Not rsTarea.EOF
strTarea = rsTarea("Nombre")
%>
<OPTION Value="<%=rsTarea("ID_Modulo")%>" > <%=strTarea%></OPTION>
<%
rsTarea.MoveNext
Loop
End If
%>
</SELECT></font></td>
</tr>
</TABLE>

<table border="0" width="100%" height="86">

<TR>
<TD height="3">

</TD>
<TD height="3">

</TD>
<TD height="3">

</TD>
<TD height="3">

</TD>
</TR>
<TR>
<TD ALIGN="center" colspan="4" height="27">

<INPUT TYPE="button" NAME "Grabar" VALUE="Grabar" ID="Grabar" onclick="Validar()" >
</TD>
</TR>
</TABLE>

</FORM>
<script language="JavaScript">
<!-- // create calendar object(s) just after form tag closed
// specify form element as the only parameter (document.forms['formname'].elements['inputname']);
// note: you can have as many calendar objects as you need for your application
var cal1 = new calendar1(document.forms['frmPaginar2'].elements['strFecha'],00,00);
cal1.year_scroll = false;
cal1.time_comp = false;


function Borrar( wValue )
{
var wRet ;

wRet = confirm('¿Seguro de borrar esta tarea?');
if ( wRet )
{
open( 'Elimina.asp?Borra=' + wValue, 'principal', null );
}
}

function Traspasar( wValue )
{
var wRet ;

wRet = 1;
}

function Validar( wParam )
{
var wRet = 0;
var wHora = 0;
var dblTiempo = 0;
var i = 0;
var cDatos = "";

if ( frmPaginar2.strFecha.value == '' ) wRet = 1

if ( frmPaginar2.strWorkProduct.value == '' ) wRet = 1

if ( frmPaginar2.strComentarios.value == '' ) wRet = 1

if ( frmPaginar2.lstTarea.selectedIndex == 0 ) wRet = 1

if ( frmPaginar2.strHora.selectedIndex == 0 )
{
if ( frmPaginar2.strMinutos.selectedIndex == 0 ) wRet = 1
}
/*---------------------------*/
if( wRet != 1 )
{
dblTiempo = frmPaginar2.strHora.selectedIndex;
if (frmPaginar2.strMinutos.selectedIndex != 0 )
{
dblTiempo += 0.5;
}
cDatos = "', #" + frmPaginar2.strFecha.value + "#, " + frmPaginar2.lstTarea.selectedIndex + ", '" + frmPaginar2.strWorkProduct.value + "', '" + frmPaginar2.strComentarios.value + "', '" + frmPaginar2.strCompleta.value + "', cDbl('" +dblTiempo + "'), #'";
cDatos = 'Grabar.asp?V1=' + frmPaginar2.strFecha.value + '&V2=' + frmPaginar2.lstTarea.selectedIndex + '&V3=' + frmPaginar2.strWorkProduct.value + '&V4=' + frmPaginar2.strComentarios.value + '&V5=' + frmPaginar2.strCompleta.value + '&V6=' + dblTiempo;
i = frmPaginar2.lstTarea.selectedIndex
open( 'Grabar.asp?V1=' + frmPaginar2.strFecha.value + '&V2=' + frmPaginar2.lstTarea.options[i].value + '&V3=' + frmPaginar2.strWorkProduct.value + '&V4=' + frmPaginar2.strComentarios.value + '&V5=' + frmPaginar2.strCompleta.value + '&V6=' + dblTiempo, 'principal', null );
}
else
{
alert('Debe Completar los campos ..... ');
}
}

//-->
</script>
<p>&nbsp;</p>
</BODY>
<SCRIPT LANGUAGE="JavaScript">

function ChangeComponente()
{
document.frmPaginar2.hid_Componente_Changed.value = "True";
document.frmPaginar2.submit();
}

function ChangeSubComponente()
{
document.frmPaginar2.hid_SubComponente_Changed.val ue = "True";
document.frmPaginar2.submit();
}
-->
</SCRIPT>
<%
' Cerrar conexiones y Recordset
Set oConn = Nothing
Set rsComponente = Nothing
Set rsSubComponente = Nothing
End Sub
%>

Lo que necesito es que, al entrar me permita cargar el último Componente, Subcomponente y Área que el usuario ingresó.

Atte.
Fernando
  #5 (permalink)  
Antiguo 17/12/2004, 12:05
Avatar de baklao  
Fecha de Ingreso: noviembre-2004
Ubicación: Santa Ana - Isla de Margarita
Mensajes: 482
Antigüedad: 19 años, 5 meses
Puntos: 0
Hola de nuevo acabo de pegar tu codigo en el frontpage para verlo mejor, ahora bien tu con esto lo que haces es buscar el componente, subcomponente y área de tu tabla hasta alli estamos bien ahora hay que buscar el ultimo que fue ingresado en tu tabla por ese usuario. porque no pones una opcion en tu tabla para que puedas saber si fue el ultimo que ha ingresado, como poner una bandera para que sepas q este fue el ultimo componente y puedas filtrar mejor tu busqueda con el where.

mmmmmm

yo tratare de ver como adapto tu codigo a lo que necesitas

Salu2.

Suerte
__________________
Atte. Mohamed :aplauso:
  #6 (permalink)  
Antiguo 17/12/2004, 12:09
 
Fecha de Ingreso: julio-2004
Mensajes: 30
Antigüedad: 19 años, 9 meses
Puntos: 0
Tengo también detectado el último registro, lo que quiero es asignarlo a las variables correspondientes, y también permitir al usuario copiar a partir de uno particular y llevar esos datos para que pueda ser agregado (exceptuando el campo fecha).

Atte.
Fernando
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:20.