Foros del Web » Programando para Internet » Javascript »

Se esperaba un objeto ';'

Estas en el tema de Se esperaba un objeto ';' en el foro de Javascript en Foros del Web. He leido en le foro para manejar selects dependientes pero no me ha sido factible adecuar ese codigo con el mio de las dos opciones ...
  #1 (permalink)  
Antiguo 24/08/2005, 10:28
 
Fecha de Ingreso: agosto-2005
Mensajes: 15
Antigüedad: 18 años, 8 meses
Puntos: 0
Exclamación Se esperaba un objeto ';'

He leido en le foro para manejar selects dependientes pero no me ha sido factible adecuar ese codigo con el mio de las dos opciones que se manejan en un foro anterior de urjose, no se si alguien me pueda colaborar y decirme que pueda estar mal. Gracias por su colaboracion anexo codigo
<head>
<title>
</title>
</head>
<body>

<%

Dim rsttask
Set rsttask = SQLQuery(cnnDB, "SELECT sc.subcat_id, sc.scategory_id, sc.sname, " & _
"st.taskname, st.iddef, st.id_subcat, ca.category_id, ca.cname " & _
"FROM sub_categories AS sc, categories AS ca, sub_task AS st " & _
"WHERE sc.subcat_id = st.id_subcat")
%>
<div align="center">
<table class="Normal">
<tr class="Head1">
<td colspan="4">
Titulos
</tr>
<tr class="Head2">
<td>
<div align="center">
titul </div>
</td>
<td>
<div align="center">
titul </div>
</td>
</tr>
<FORM NAME="Listas" METHOD="POST" ACTION="viewtask.asp">
<tr class="Body1"> <!-- LISTAS DEPENDIENTES DE CATEGORIAS Y SUBCATEGORIAS -->
<td align="center">
<SELECT NAME="Categories" SIZE="1"
OnChange="componerlista (document.forms.Listas.Categories[selectedIndex].value);">
<%
' Get list of categories to display
Dim rstCatList, namecat, idcat, aux
Set rstCatList = SQLQuery(cnnDB, "SELECT * FROM categories " & _
"WHERE category_id > 0 ORDER BY cname ASC")
aux = 1
While Not rstCatList.EOF
%>
<OPTION VALUE="<%=rstCatList("category_id")%>">
<%If aux = 1 Then %>
<SELECTED>
<% End If %>
<%=rstCatList("cname")%></OPTION>
<%
rstCatList.Movenext
aux = aux + 1
Wend
rstCatList.Close
%>
</SELECT><em>*</em>
</td>
<td align="center">
<SELECT NAME="subcat" SIZE="1">
</SELECT>
</td>
</tr>
<p><INPUT TYPE="submit"></p>
</FORM>
<SCRIPT LANGUAGE="javascript">
<!--
function Tupla ( campo1, campo2 )
{
this.campo1 = campo1;
this.campo2 = campo2;
}
<%
'Vamos a crear nuestros arrays de productos desde ASP
'El primer IF detecta un cambio en la categoría
'para crear un nuevo array en Javascript
%>
<%
Dim rstsubcate, cat
Set rstsubcate = SQLQuery(cnnDB,"SELECT * FROM sub_categories ORDER BY scategory_id, subcat_id")
aux = 0
cat="basura"
response.Write(rstsubcate("subcat_id"))
While Not rstsubcate.EOF
If cat <> rstsubcate("scategory_id") Then
'cambio de categoria, empiezo a contar en 0
aux = 0
cat = Cint(rstsubcate("scategory_id"))
'Además tengo que crear un nuevo array para la categoría
%>
var opciones <%=cat%> = new Array();
<%
End If
%>
opciones<%=cat%>[<%=aux%>]=new Tupla("<%=rstsubcate("sname")%>","<%=rstsubcate("s ubcat_id")%>");

<%
aux = aux + 1
rstsubcate.MoveNext
wend
%>

<%
'Limpiamos objetos
rstsubcate.Close
Set rstsubcate=nothing
%>
var contador;

function ComponerLista ( array )
{
// Compone la lista dependiente a partir
// del valor de la opcion escogida en la lista "padre"
BorrarLista();
array = eval("opciones" + array);

for (contador=0; contador<array.length; contador++)
{
// añade elementos nuestro combobox
var optionObj = new Option( array[contador].campo1, array[contador].campo2 );

Listas.Productos.options[contador] = optionObj;
} // for
} // ComponerLista


function BorrarLista()
{
Listas.subcat.length=0;
}

//Inicializamos
ComponerLista (1);
-->
</SCRIPT>
</FORM>
</table>
</body>
__________________
JOSE GARCIA :-) :arriba:

Última edición por Saletoby; 24/08/2005 a las 12:05
  #2 (permalink)  
Antiguo 24/08/2005, 18:09
Avatar de lexus  
Fecha de Ingreso: enero-2002
Ubicación: Cali - Colombia
Mensajes: 2.234
Antigüedad: 22 años, 4 meses
Puntos: 4
http://www.asptutor.com/asp/vart.asp?id=102

Código:
 <html> 

<head>
<title>Combos combinados</title>

<script language = "JavaScript">

 

<%'CONSULTA PARA OBTENER LOS DATOS
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("\database\hard.mdb"))

productos_Sql = "Select distinct familia, codigo, denominacion from articulos "
set rs = CreateObject("ADODB.Recordset")
rs.Open productos_Sql, Conn
x=0
%>

// FUNCION DE COMBO BOX COMBINADO

function sublist(inform, selecteditem)
{
inform.subcatagory.length = 0

<%
count= 0
y=0
do while not rs.eof
%>

x = <%= trim(y) %>;

subcat = new Array();
subcatagorys = "<%=(rs("codigo"))&" "&(rs("denominacion")) %>";
subcatagoryof = "<%=(rs("familia"))%>";
subcatagoryid = "<%=(rs("codigo"))%>";
subcat[x,0] = subcatagorys;
subcat[x,1] = subcatagoryof;
subcat[x,2] = subcatagoryid;
if (subcat[x,1] == selecteditem) {
var option<%= trim(count) %> = new Option(subcat[x,0], subcat[x,2]);
inform.subcatagory.options[inform.subcatagory.length]=option<%= trim(count)%>;
}
<%
count = count + 1
y = y + 1
rs.movenext
loop
rs.close
%>
}

</script>

 

</head>

<body bgcolor="#CDB1B7">
<h2 align="center"><b><i><font color="#AE1732"><u>Combo-box enlazados </u></font></i></b></h2>
<form name="prueba">
<div align="center">
<center>
<table border="0" width="80%">
<tr>

<td width="77%">
<select size="1" id="familia" name="familia" onChange = "javascript:sublist(this.form, familia.value);">

<option selected>Selecciona una familia</option>
<%familias_Sql = "Select distinct id,familia from familias"
rs.Open familias_Sql, Conn
do while not rs.eof
%>
<option value="<%=rs("id")%>"><%=rs("familia")%></option>


<%rs.movenext
loop
set rs=nothing
conn.close
set conn=nothing%>
</select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SELECT id="subcatagory" name="subcatagory" size="1">
<Option selected value="none"></option>
</SELECT></td>
<td width="9%">
<p align="left">

</p>

</td>
</tr>
</table>
</center>
</div>
<center>
</form>
</center>
</body>
</html>
__________________
Control de Visitantes, Control de Accesos, Minutas digitales, Manejo de Correspondencia
http://www.controldevisitantes.com
  #3 (permalink)  
Antiguo 26/08/2005, 09:01
 
Fecha de Ingreso: marzo-2004
Ubicación: trujillo
Mensajes: 22
Antigüedad: 20 años, 1 mes
Puntos: 0
chekeam el codigo de lexus esta bien estructurado y no te comliques mas ....saludos
  #4 (permalink)  
Antiguo 30/08/2005, 06:54
 
Fecha de Ingreso: agosto-2005
Mensajes: 15
Antigüedad: 18 años, 8 meses
Puntos: 0
He adecuedo el codigo de lexus y la pagina queda en blanco, no muestra errores y nada de eso, sera que hice mal la adecuacion, aqui anexo la adecuacion del codigo de Lexus a mi estructura sera que le puse algo mal ????

<%@ LANGUAGE="VBScript" %>
<%
Option Explicit
'Buffer the response, so Response.Expires can be used
Response.Buffer = TRUE
%>

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<!--

Filename: viewsubdef.asp
Date: $Date: 2005/08/19 17:00:50 $
Version: $Revision: 1.00 $
Purpose: This is the administrative Task.
-->

<!-- #include file = "../public.asp" -->

<%

Dim cnnDB, sid
Set cnnDB = CreateCon
sid = GetSid
%>

<head>
<title>
<%=lang(cnnDB, "HelpDesk")%>&nbsp;-&nbsp;<%=lang(cnnDB, "Manage")%>&nbsp;<%=lang(cnnDB, "subdef")%>
</title>
<link rel="stylesheet" type="text/css" href="../default.css">
<script language = "JavaScript">
<%
'CONSULTA PARA OBTENER LOS DATOS
Dim rstsubcate
Set rstsubcate = SQLQuery(cnnDB, "SELECT DISTINCT scategory_id, subcat_id, sname FROM sub_task")
x=0
%>

// FUNCION DE COMBO BOX COMBINADO

function sublist(inform, selecteditem)
{
inform.subcatagory.length = 0
<%
count = 0
y = 0
Do While Not rstsubcate.EOF
%>

x = <%= trim(y) %>;
subcat = new Array();
subcatagorys = "<%=(rstsubcate("subcat_id"))&" "&(rstsubcate("sname")) %>";
subcatagoryof = "<%=(rstsubcate("scategory_id"))%>";
subcatagoryid = "<%=(rstsubcate("subcat_id"))%>";
subcat[x,0] = subcatagorys;
subcat[x,1] = subcatagoryof;
subcat[x,2] = subcatagoryid;
If (subcat[x,1] == selecteditem)
{
var option<%=trim(count)%> = new Option(subcat[x,0], subcat[x,2]);
inform.subcatagory.options[inform.subcatagory.length]=option<%= trim(count)%>;
}
<%
count = count + 1
y = y + 1
rstsubcate.movenext
Loop
rstsubcate.close
%>
}
</script>
</head>
<body>
<%
' Check for perms to view this page
Call CheckAdmin
%>
<div align="center">
<table class="Normal">
<tr class="Head1">
<td colspan="4">
<%=lang(cnnDB, "subdef")%> </td>
</tr>
<tr class="Head2">
<td>
<div align="center">
<%=lang(cnnDB, "categories")%>
</div>
</td>
<td>
<div align="center">
<%=lang(cnnDB, "subcat")%>
</div>
</td>
</tr>
<FORM NAME="Listas" METHOD="POST" ACTION="viewtask.asp">
<tr class="Body1"> <!-- LISTAS DEPENDIENTES DE CATEGORIAS Y SUBCATEGORIAS -->
<td align="center">
<SELECT size="1" id="categ" name="categ" onChange = "javascript:sublist(this.form, categ.value);">
<OPTION SELECTED>Seleccione una <%=lang(cnnDB, "cat")%></OPTION>
<% Dim rstcate
Set rstcate = SQLQuery(cnnDB, "SELECT DISTINCT category_id, cname FROM categories")
Do While Not rstcate.EOF
%>
<OPTION VALUE="<%=rstcate("category_id")%>"><%=rstcate("cn ame")%></OPTION>
<%
rstcate.Movenext
Loop
rstcate.Close
%>
</SELECT>
</td>
<td>
<SELECT id="subcatagory" name="subcatagory" size="1">
<OPTION SELECTED value="none"></OPTION>
</SELECT>
</td>
</tr>
</FORM>
</table>
</body>
__________________
JOSE GARCIA :-) :arriba:
  #5 (permalink)  
Antiguo 05/09/2005, 07:18
 
Fecha de Ingreso: agosto-2005
Mensajes: 15
Antigüedad: 18 años, 8 meses
Puntos: 0
Ya estructure el codigo de Lexus y ahora me esta generando el siguiente error de pagina de Internet Explorer

Linea 30
Car 3
Error Caracter no Valido
Codigo 0
URL http://aplicativo/pagina.asp
__________________
JOSE GARCIA :-) :arriba:
  #6 (permalink)  
Antiguo 05/09/2005, 11:08
Avatar de El_Metallick  
Fecha de Ingreso: noviembre-2002
Ubicación: Santiago, Chile
Mensajes: 1.718
Antigüedad: 21 años, 5 meses
Puntos: 16
cual es la linea 30???? no pretenderas que las contemos o si :S jajajajajaj seria para volverse loco
__________________
Haz la guerra en la cama y el amor donde se te de la gana...
El tiempo es el mejor maestro, lo único malo es que te mata...¡¡Aprovecha tu tiempo!!
  #7 (permalink)  
Antiguo 09/09/2005, 06:57
 
Fecha de Ingreso: agosto-2005
Mensajes: 15
Antigüedad: 18 años, 8 meses
Puntos: 0
<%

Dim cnnDB, sid
Set cnnDB = CreateCon
sid = GetSid
%>

Al finalizar esta instruccion es la linea 30, es decir carga la pagina pero no muestra los datos en el segundo combo box.
__________________
JOSE GARCIA :-) :arriba:
  #8 (permalink)  
Antiguo 09/09/2005, 07:22
Avatar de tunait
Moderadora
 
Fecha de Ingreso: agosto-2001
Ubicación: Terok Nor
Mensajes: 16.805
Antigüedad: 22 años, 8 meses
Puntos: 381
Buenas,

ese error que obtienes es de javascript, así que debes de buscar la línea 30 del código que le llega al navegador y no en el código que contiene el asp
  #9 (permalink)  
Antiguo 09/09/2005, 10:02
Avatar de AlZuwaga
Colaborador
 
Fecha de Ingreso: febrero-2001
Ubicación: 34.517 S, 58.500 O
Mensajes: 14.550
Antigüedad: 23 años, 2 meses
Puntos: 535
Opsss.. movido desde ASP ;)
__________________
...___...
  #10 (permalink)  
Antiguo 26/09/2005, 14:20
 
Fecha de Ingreso: agosto-2005
Mensajes: 15
Antigüedad: 18 años, 8 meses
Puntos: 0
ok Gracias
__________________
JOSE GARCIA :-) :arriba:
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 09:23.