Foros del Web » Programando para Internet » ASP Clásico »

Agregando Div, E Insertandolas En Bd Access

Estas en el tema de Agregando Div, E Insertandolas En Bd Access en el foro de ASP Clásico en Foros del Web. Saludos amigos, Tengo aca un formulario de cotización q contiene un java q me crea otros campos, pero quisiera saber si hay una forma de ...
  #1 (permalink)  
Antiguo 14/02/2008, 12:21
Avatar de PedroJTR  
Fecha de Ingreso: febrero-2008
Ubicación: Guarenas, Venezuela
Mensajes: 116
Antigüedad: 16 años, 4 meses
Puntos: 1
Pregunta Agregando Div, E Insertandolas En Bd Access

Saludos amigos,
Tengo aca un formulario de cotización q contiene un java q me crea otros campos, pero quisiera saber si hay una forma de q estos nuevos q se van llenando se agregan en la base de datos en acces como otros registros.
O se reemplazan por los de arriba!!

Please, alguien me da una manito?

Código PHP:
<head>
<
script type="text/javascript" language="JavaScript">
function 
addNewRow(){
var 
TABLE document.getElementById("base");
var 
TROW document.getElementById("example");
var 
content TROW.getElementsByTagName("td");
var 
newRow TABLE.insertRow(-1);
newRow.className TROW.attributes['class'].value;
insertLOselect(content,newRow);
var 
newRow2 TABLE.insertRow(-1);
newRow2.className TROW.attributes['class'].value;
//window.alert(content);
copyRow(content,newRow2);
}
function 
removeLastRow() {
var 
TABLE document.getElementById("base");
if(
TABLE.rows.length 2) {
TABLE.deleteRow(TABLE.rows.length-1);
TABLE.deleteRow(TABLE.rows.length-1);
}
}
function 
appendCell(Trowtxt) {
var 
newCell Trow.insertCell(Trow.cells.length)
newCell.innerHTML txt
}
function 
copyRow(content,Trow) {
var 
cnt 0;
for (; 
cnt content.lengthcnt++) {
appendCell(Trowcontent[cnt].innerHTML);
}
}
function 
insertLOselect(content,Trow) {
var 
cnt 0;
for (; 
cnt content.length-1cnt++) {
appendCell(Trow'&nbsp;');
}
}
</script></head>
<form id="form1" name="form1" method="post" action="">
                <table width="507" border="0" cellpadding="1" cellspacing="2">
                  <tr>
                    <td colspan="8"><table width="100%" border="0" cellspacing="2" cellpadding="0">
                      <tr>
                        <td width="95%"><div align="right"><strong>CÓDIGO ORDEN</strong></div></td>
                        <td width="5%">
 
                            <div align="left"><strong>
                              <input name="id_orden" type="text" class="TEXT_AREA" id="id_orden" onkeyup="this.value=this.value.toUpperCase()" size="8" maxlength="15" readonly />
                            </strong></div></td>
                      </tr>
                    </table></td>
                    </tr>
                  <tr>
                    <td width="54"><p align="left"><strong>CLIENTE </strong></p>                      </td>
                    <td width="419" colspan="7"><div align="left">
                      <table width="100%" border="0" cellspacing="2" cellpadding="0">
                        <tr>
                          <td width="37%"><div align="left"><strong>
                            <input name="id_cte" type="text" class="TEXT_AREA" id="id_cte" onkeyup="this.value=this.value.toUpperCase()" size="10" maxlength="8" style="color:gray" onfocus="color(this,0,'COD. CLIENTE')" onblur="color(this,1,'COD. CLIENTE')" value="COD. CLIENTE"/>
                          </strong></div></td>
                          <td width="63%"><div align="left">
                            <select name="lis_cte" class="TEXT_AREA" id="lis_cte">
                              <option>--Seleccione un cliente--</option>
                            </select>
                          </div></td>
                        </tr>
                      </table>
                      </div></td>
                  </tr><tr>
                      <td height="30" colspan="8">                                        <div align="center">
                        <label>                        </label>
                        <table width="100%" border="0" cellspacing="2" cellpadding="0">
 
                          <tr>
                            <td height="14" colspan="2" valign="bottom"><table width="100%" border="0" align="center" id="base">
<tr class="celda">
<td width="18%" class="Estilo1" style="padding:3px;"><div align="center"><strong>CANTIDAD</strong></div></td>
<td width="24%" class="Estilo1" style="padding:3px;"><div align="center"><strong>SERVICIO</strong></div></td>
<td width="16%" class="Estilo1" style="padding:3px;"><div align="center" class="Estilo2">
  <p>GASTO</p>
  </div></td>
<td width="21%" class="Estilo1" style="padding:3px;"><div align="center"><strong>COSTO</strong></div></td>
<td width="19%" class="Estilo1" style="padding:3px;"><div align="center"><strong>TOTAL</strong></div></td>
<td width="2%">&nbsp;</td>
</tr>
<tr id="example" class="celda">
<td align="center" valign="middle"><input name='cantidad' type='text' class="TEXT_AREA" id='cantidad' value="00" size="2" maxlength="2" style="color:gray" onfocus="color(this,0,'00')" onblur="color(this,1,00')"/></td>
<td align="center" valign="middle" style='padding:3px;'><div align="center">
  <select class="TEXT_AREA" name="id_serv" id="opera">
    <option>--Seleccione un servicio--</option>
  </select>
</div></td>
<td align="center" valign="middle"><div align="center">
  <input name='gasto' type='text' class="TEXT_AREA" id='gasto' value="00" size="5" maxlength="5" style="color:gray" onfocus="color(this,0,'00')" onblur="color(this,1,00')"/>
</div></td>
<td align="center" valign="middle"><div align="center">
  <input name='costo' type='text' class="TEXT_AREA" id='costo' value="00" size="5" maxlength="5" style="color:gray" onfocus="color(this,0,'00')" onblur="color(this,1,00')"/>
</div></td>
<td align="center" valign="middle"><div align="center">
  <input name='total' type='text' class="TEXT_AREA" id='total' value="00" size="5" maxlength="5" style="color:gray" onfocus="color(this,0,'00')" onblur="color(this,1,00')" readonly="readonly"/>
  <input type="hidden" name="btnAction" value="next" />
</div></td>
</tr>
</table>                               
                              </td>
                          </tr>
                          <tr>
                            <td height="23" colspan="2" valign="top"><div align="center"><input type="button" class="boton" value="[+]" onClick="addNewRow(event)" alt="Adicionar">
<input type="button" class="boton" value="[-]" onClick="removeLastRow(event)" alt="Remover"></div></td>
                            </tr>
                          <tr>
                            <td height="14" valign="top">&nbsp;</td>
                            <td valign="bottom">&nbsp;</td>
                          </tr>
                          <tr>
                            <td width="19%" height="14" valign="top"><strong>OBSERVACIONES</strong></td>
                            <td width="81%" valign="bottom"><div align="left">
                              <textarea name="ob_oservicio" cols="45" rows="5" class="TEXT_AREA" id="ob_oservicio" style="color:gray" onfocus="color(this,0,'OBSERVACIONES')" onblur="color(this,1,'OBSERVACIONES')" onkeyup="this.value=this.value.toUpperCase()" value="OBSERVACIONES">OBSERVACIONES</textarea>
                            </div></td>
                          </tr>
                          <tr>
                            <td height="35" colspan="2" valign="bottom"><div align="center">
                              <input name="enviar" type="submit" class="TEXT_AREA" id="enviar" value="INGRESAR CLIENTE" />
                            </div>
                              <div align="left"></div></td>
                            </tr>
                        </table>
                        <label></label>
                      </div>
                    </table>
                            </form> 

Última edición por PedroJTR; 15/02/2008 a las 09:53
  #2 (permalink)  
Antiguo 14/02/2008, 16:03
 
Fecha de Ingreso: octubre-2007
Mensajes: 76
Antigüedad: 16 años, 8 meses
Puntos: 1
Re: Agregando Div, E Insertandolas En Bd Access

par poder ayudarte es necesario que pongas el codigo con el cual trabajas, de otra forma no podremos hacernada, ya que solo mandeste el HTML con algo de JAVASCRIPT
saludos.
  #3 (permalink)  
Antiguo 15/02/2008, 09:53
Avatar de PedroJTR  
Fecha de Ingreso: febrero-2008
Ubicación: Guarenas, Venezuela
Mensajes: 116
Antigüedad: 16 años, 4 meses
Puntos: 1
Re: Agregando Div, E Insertandolas En Bd Access

Cita:
Iniciado por rene_bustos Ver Mensaje
par poder ayudarte es necesario que pongas el codigo con el cual trabajas, de otra forma no podremos hacernada, ya que solo mandeste el HTML con algo de JAVASCRIPT
saludos.
Ohh.. Si.. Sorry!!!
Ya lo edité!!

Código PHP:
<script type="text/javascript" language="JavaScript">
function 
addNewRow(){
var 
TABLE document.getElementById("base");
var 
TROW document.getElementById("example");
var 
content TROW.getElementsByTagName("td");
var 
newRow TABLE.insertRow(-1);
newRow.className TROW.attributes['class'].value;
insertLOselect(content,newRow);
var 
newRow2 TABLE.insertRow(-1);
newRow2.className TROW.attributes['class'].value;
//window.alert(content);
copyRow(content,newRow2);
}
function 
removeLastRow() {
var 
TABLE document.getElementById("base");
if(
TABLE.rows.length 2) {
TABLE.deleteRow(TABLE.rows.length-1);
TABLE.deleteRow(TABLE.rows.length-1);
}
}
function 
appendCell(Trowtxt) {
var 
newCell Trow.insertCell(Trow.cells.length)
newCell.innerHTML txt
}
function 
copyRow(content,Trow) {
var 
cnt 0;
for (; 
cnt content.lengthcnt++) {
appendCell(Trowcontent[cnt].innerHTML);
}
}
function 
insertLOselect(content,Trow) {
var 
cnt 0;
for (; 
cnt content.length-1cnt++) {
appendCell(Trow'&nbsp;');
}
}
</script> 
  #4 (permalink)  
Antiguo 15/02/2008, 12:07
Avatar de Shiryu_Libra
Colaborador
 
Fecha de Ingreso: febrero-2007
Ubicación: Cantando "Screenager" en "Kirafa Kaput"
Mensajes: 3.614
Antigüedad: 17 años, 3 meses
Puntos: 88
Re: Agregando Div, E Insertandolas En Bd Access



puedes dejar tu codigo tal cual esta, existe en la coleccion del FORM, un atributo que se llama COUNT, que nos permitiria tomar todos los valores de un textbox con el mismo nombre

un ejemplo en la pagina de recepcion de datos quedaria asi...... considerando la forma rapida de rene que puso EN ESTE POST

Código PHP:
<%
if 
request.ServerVariables("REQUEST_METHOD")="POST" then
    dim cantidad
()
    
dim id_serv()
    
dim gasto()
    
dim costo()
    
dim total()

    for 
i=1 to request.form("cantidad").count
        redim preserve cantidad
(i-1)
        
cantidad(i-1) = request.form("cantidad")(i)
    
next
    
for i=1 to request.form("id_serv").count
        redim preserve id_serv
(i-1)
        
id_serv(i-1) = request.form("id_serv")(i)
    
next
    
for i=1 to request.form("gasto").count
        redim preserve gasto
(i-1)
        
gasto(i-1) = request.form("gasto")(i)
    
next
    
for i=1 to request.form("costo").count
        redim preserve costo
(i-1)
        
costo(i-1) = request.form("costo")(i)
    
next
    
for i=1 to request.form("total").count
        redim preserve total
(i-1)
        
total(i-1) = request.form("total")(i)
    
next

    response
.Write "Cuantas " i
    
%><table><%
    for 
j=0 to ubound(cantidad)
        %><
tr>
            <
td><%=cantidad(j)%></td>
            <
td><%=id_serv(j)%></td>
            <
td><%=gasto(j)%></td>
            <
td><%=costo(j)%></td>
            <
td><%=total(j)%></td>
        </
tr><%
    
next
    
%></table><%end if%> 
mmmm funcionara????
__________________
"Eres parte del problema, parte de la solucion o parte del paisaje"
Un Saludo desde Desierto de Altar, Sonora, MX.
Shiryu_libra
  #5 (permalink)  
Antiguo 15/02/2008, 12:55
 
Fecha de Ingreso: octubre-2007
Mensajes: 76
Antigüedad: 16 años, 8 meses
Puntos: 1
De acuerdo Re: Agregando Div, E Insertandolas En Bd Access

Que onda asi es shiryu_Libra debe de funcionar la verdad que la forma en que pusiste el codigo es una de las mejores que he visto y que es claro y ordenado
solamente tengo una pequña duda en esta parte del codigo

cantidad(i-1) = request.form("cantidad")(i)

e imagino que lo que haces es agregar al arreglo cantidad el valor de cada elemento de request.form("cantidad") vdd?

gracias y buen codigo

oye pedroJTR ya has podido insertar los datos??
  #6 (permalink)  
Antiguo 15/02/2008, 13:40
Avatar de PedroJTR  
Fecha de Ingreso: febrero-2008
Ubicación: Guarenas, Venezuela
Mensajes: 116
Antigüedad: 16 años, 4 meses
Puntos: 1
Pregunta Re: Agregando Div, E Insertandolas En Bd Access

Cita:
Iniciado por Shiryu_Libra Ver Mensaje


puedes dejar tu codigo tal cual esta, existe en la coleccion del FORM, un atributo que se llama COUNT, que nos permitiria tomar todos los valores de un textbox con el mismo nombre

un ejemplo en la pagina de recepcion de datos quedaria asi...... considerando la forma rapida de rene que puso EN ESTE POST

Código PHP:
<%
if 
request.ServerVariables("REQUEST_METHOD")="POST" then
    dim cantidad
()
    
dim id_serv()
    
dim gasto()
    
dim costo()
    
dim total()
 
    for 
i=1 to request.form("cantidad").count
        redim preserve cantidad
(i-1)
        
cantidad(i-1) = request.form("cantidad")(i)
    
next
    
for i=1 to request.form("id_serv").count
        redim preserve id_serv
(i-1)
        
id_serv(i-1) = request.form("id_serv")(i)
    
next
    
for i=1 to request.form("gasto").count
        redim preserve gasto
(i-1)
        
gasto(i-1) = request.form("gasto")(i)
    
next
    
for i=1 to request.form("costo").count
        redim preserve costo
(i-1)
        
costo(i-1) = request.form("costo")(i)
    
next
    
for i=1 to request.form("total").count
        redim preserve total
(i-1)
        
total(i-1) = request.form("total")(i)
    
next
 
    response
.Write "Cuantas " i
    
%><table><%
    for 
j=0 to ubound(cantidad)
        %><
tr>
            <
td><%=cantidad(j)%></td>
            <
td><%=id_serv(j)%></td>
            <
td><%=gasto(j)%></td>
            <
td><%=costo(j)%></td>
            <
td><%=total(j)%></td>
        </
tr><%
    
next
    
%></table><%end if%> 
mmmm funcionara????
Shiryu_Libra. te pasaste...
Gracias, ahora solo tendría que hacer el INSERT en la base de datos y el me los tomará todos Verdad?
  #7 (permalink)  
Antiguo 15/02/2008, 15:22
 
Fecha de Ingreso: octubre-2007
Mensajes: 76
Antigüedad: 16 años, 8 meses
Puntos: 1
De acuerdo Re: Agregando Div, E Insertandolas En Bd Access

muy correcto solo falta hacer el insert recuerda validar los datos que te lleguen o.k? que no vengan nulos, con comillas simples, expresiones de logica, etc
cualquier duda para eso estamos todos.
saludos y nos dices como te fue.
  #8 (permalink)  
Antiguo 16/02/2008, 11:27
Avatar de PedroJTR  
Fecha de Ingreso: febrero-2008
Ubicación: Guarenas, Venezuela
Mensajes: 116
Antigüedad: 16 años, 4 meses
Puntos: 1
Re: Agregando Div, E Insertandolas En Bd Access

Cita:
Iniciado por rene_bustos Ver Mensaje
muy correcto solo falta hacer el insert recuerda validar los datos que te lleguen o.k? que no vengan nulos, con comillas simples, expresiones de logica, etc
cualquier duda para eso estamos todos.
saludos y nos dices como te fue.
Sin duda!!!
Con gusto les diré que tal!!
Saludos!!!
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 22:43.