Foros del Web » Programando para Internet » Javascript »

validar el primer registro de un combo ???

Estas en el tema de validar el primer registro de un combo ??? en el foro de Javascript en Foros del Web. estimado amigos tengo un cosigo de java script con dos combos enlazados el 1 levanta una categoria y el segundo lvanta la sub de la ...
  #1 (permalink)  
Antiguo 23/03/2007, 12:15
Avatar de cjzava  
Fecha de Ingreso: enero-2006
Mensajes: 41
Antigüedad: 18 años, 3 meses
Puntos: 1
validar el primer registro de un combo ???

estimado amigos tengo un cosigo de java script con dos combos enlazados

el 1 levanta una categoria y el segundo lvanta la sub de la categoria ingresada hasta todo bien , mi problema es tengo que ponerle que no puedan enviar el primer registro de los dos quisiera saber si alguien sabe como hacerlo les dejo el codigo que estoy utilizando
desde ya muchas gracias


<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">

<!--



// Initialize class for Type and Style



function Type(id, type){

this.id = id;

this.type = type;

}



function Style(id, id_type, style){

this.id = id;

this.id_type = id_type;

this.style = style;

}



// Initialize Array's Data for Type and Style



TypeArray = new Array(

new Type(1, "Noticias"),

new Type(2, "Personales"),

new Type(3, "Politica"),

new Type(4, "Arte y Cultura"),

new Type(5, "Tecnologia"),

new Type(6, "Entretenimiento"),

new Type(7, "Ciencias")

);



StyleArray = new Array(


//subcategorias de moticias 1

new Style("Noticias",1, "Noticias"),

new Style("Opinion",1, "Opinion"),


//subcategorias de personales 2

new Style("Autos", 2, "Autos"),

new Style("Deportes", 2, "Deportes"),

new Style("Humor", 2, "Humor"),

new Style("Sociedad", 2, "Sociedad"),

new Style("Viajes y Turismo", 2, "Viajes y Turismo"),


//subcategorias de politica 3

new Style("Politica Social", 3, "Politica Social"),



//subcategorias de arte y cultura 4

new Style("Cuentos y Relatos", 4, "Cuentos y Relatos"),

new Style("Literatura", 4, "Literatura"),

new Style("Musica", 4, "Musica"),

new Style("Educación", 4, "Educación"),

new Style("Economia", 4, "Economia"),

new Style("Literatura", 4, "Literatura"),



//subcategorias de tecnologia 5

new Style("Internet", 5, "Internet"),

new Style("Diseño Web", 5, "Diseño Web"),

new Style("Software", 5, "Software"),

new Style("Hardware", 5, "Hardware"),



//subcategorias de entretenimiento 6

new Style("Cine", 6, "Cine"),

new Style("TV", 6, "TV"),

new Style("Entretenimientos", 6, "Entretenimientos"),


//subcategorias de ciencias 7

new Style("Ciencia", 7, "Ciencia"),

new Style("Salud", 7, "Salud")








);





function init(sel_type, sel_style){



document.product.id_type.options[0] = new Option(" Todas las Categoria ");

document.product.id_style.options[0] = new Option(" Todas las SubCategoria ");

for(i = 1; i <= TypeArray.length; i++){

document.product.id_type.options[i] = new Option(TypeArray[i-1].type, TypeArray[i-1].id);

if(TypeArray[i-1].id == sel_type)

document.product.id_type.options[i].selected = true;

}

OnChange(sel_style);



}



function OnChange(sel_style){



sel_type_index = document.product.id_type.selectedIndex;

sel_type_value = parseInt(document.product.id_type[sel_type_index].value);



for(i = document.product.id_style.length - 1; i > 0; i--)

document.product.id_style.options[i] = null;



j=1;

for(i = 1; i <= StyleArray.length; i++){

if(StyleArray[i-1].id_type == sel_type_value){

document.product.id_style.options[j] = new Option(StyleArray[i-1].style, StyleArray[i-1].id);

if(StyleArray[i-1].id == sel_style) document.product.id_style.options[j].selected = true;

j++;

}

}



}

//-->

</SCRIPT>


<form>

<select name="id_type" size="1" style="width: 228;height:228" onChange="OnChange()">
<select name="id_style" size="1" style="width: 228;height:228">

</form>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">

<!--

// init(5, 31); // Initialize comboboxes by selected sel_type and sel_style

init(); // Default initialize comboboxes for Type and Style

//-->

</SCRIPT>
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 01:08.