Pregunta: | 68123 - MULTIPLES MENUS DE SALTO CON UN BOTON DE SUBMIT |
Autor: | Fernando LIc |
HOLA, QUERIA VER SI ALGUIEN PUEDRA SABER ALGO AL RESPECTO. HE ENCONTRADO UN CODIGO QUE HA PERMITIDO TENER SOLO 2 MENUS DE SALTO CON UN BOTON SUBMIT, SIN EMBARGO A LA HORA QUE QUIERO INCREMENTAR OTRO MENU DE SALTO, ME MARCA ERRORES DE SINTAXIS Y POR MAS QUE ENCUENTRO MI LOGICA NO VEO EL ERROR. PORFAVOR SI ALGUIEN SUPIDERA LO AGRADECERIA MUCHO. DEGO AQUI AMBOS CODIGOS EL ORIGINAL Y EL QUE HE QUERIDO EDITAR. ORIGINAL. <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Documento sin título</title> </head> <body> <script type="text/javascript"> function MM_resolveTargetUrl(firstObjId,secondObjId,targ,restore){ var firstSelObj = null; var secondSelObj = null; with (document){ if (getElementById) { firstSelObj = getElementById(firstObjId); secondSelObj = getElementById(secondObjId); }// end if // WARNING: The following logic will only work if the initial values of the dropdown boxes are ---TEST1--- and ---TEST2--- // Change the if condition if the initial values are something else!! if (firstSelObj.value == "---TEST1---"){ // user has not selected from first dropdown if (secondSelObj.value == "---TEST2---") { // user has not selected from the second dropdown alert("Please select an option from the dropdown menus!"); return }// end nested if else { // user has selected from the second dropdown eval(targ+".location='"+secondSelObj.options[secondSelObj.selectedIndex].value+"'"); if (restore) firstSelObj.selectedIndex=0; if (restore) secondSelObj.selectedIndex=0; return; }// end nested else }// end if else { // user has selected from the first dropdown eval(targ+".location='"+firstSelObj.options[firstSelObj.selectedIndex].value+"'"); if (restore) firstSelObj.selectedIndex=0; if (restore) secondSelObj.selectedIndex=0; return; }// end else }// end with }// end MM_resolveTargetUrl </script> </head> <body> <form name="form" id="form" accept-charset="" > <!-- WARNING: There is logic in the MM_resolveTargetUrl function above that relies on the initial values of the dropdown boxes. If the initial values ---TEST1--- and ---TEST2--- change, the if conditions in the function must be changed as well!! --> <select name="jumpMenu" id="jumpMenu" style="background-color:#fff; width:150px; color:#666;"> <option selected = "TEST1" class="red" style="font-size: 0.9em; font-family: Arial; text-indent:0.3em; ">---TEST1---</option> <option value="http://www.google.com" style="font-size: 0.9em; font-family: Arial;">GOOGLE</option> </select> <!-- WARNING: There is logic in the MM_resolveTargetUrl function above that relies on the initial values of the dropdown boxes. If the initial values ---TEST1--- and ---TEST2--- change, the if conditions in the function must be changed as well!! --> <select name="jumpMenu2" id="jumpMenu2" style="background-color:#000; width:150px; color:#CCC;"> <option selected = "TEST2" style="font-size: 0.9em; font-family: Arial;">---TEST2---</option> <option value="http://www.yahoo.com" style="font-size: 0.9em; font-family: Arial;">YAHOO</option> </select> <input type="button" name="go_button" id= "go_button" value="Go" onClick="MM_resolveTargetUrl('jumpMenu','jumpMenu2','parent',1)" > </legend> </form> </body> </html> EL QUE HE QUERIDO EDITRAR <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Documento sin título</title> </head> <body> <script type="text/javascript"> function MM_resolveTargetUrl(firstObjId,secondObjId,tercer,targ,restore){ var firstSelObj = null; var secondSelObj = null; var tercer = null; with (document){ if (getElementById) { firstSelObj = getElementById(firstObjId); secondSelObj = getElementById(secondObjId); tercer = getElementById(tercerId); }// end if // WARNING: The following logic will only work if the initial values of the dropdown boxes are ---TEST1--- and ---TEST2--- // Change the if condition if the initial values are something else!! if (firstSelObj.value == "---TEST1---"){ // user has not selected from first dropdown if (secondSelObj.value == "---TEST2---") { // user has not selected from the second dropdown if (tercer.value == "---TEST3---") { // user has not selected from the second dropdown alert("Please select an option from the dropdown menus!"); return }// end nested if else { // user has selected from the second dropdown eval(targ+".location='"+secondSelObj.options[secondSelObj.selectedIndex].value+"'"); if (restore) firstSelObj.selectedIndex=0; if (restore) secondSelObj.selectedIndex=0; if (restore) tercer.selectedIndex=0; return; }// end nested else }// end if else { // user has selected from the first dropdown eval(targ+".location='"+firstSelObj.options[firstSelObj.selectedIndex].value+"'"); if (restore) firstSelObj.selectedIndex=0; if (restore) secondSelObj.selectedIndex=0; if (restore) tercer.selectedIndex=0; return; }// end else }// end with }// end MM_resolveTargetUrl eval(targ+".location='"+tercer.options[tercer.selectedIndex].value+"'"); if (restore) firstSelObj.selectedIndex=0; if (restore) secondSelObj.selectedIndex=0; if (restore) tercer.selectedIndex=0; return; }// end else }// end with }// end MM_resolveTargetUrl </script> </head> <body> <form name="form" id="form" accept-charset="" > <!-- WARNING: There is logic in the MM_resolveTargetUrl function above that relies on the initial values of the dropdown boxes. If the initial values ---TEST1--- and ---TEST2--- change, the if conditions in the function must be changed as well!! --> <select name="jumpMenu" id="jumpMenu" style="background-color:#fff; width:150px; color:#666;"> <option selected = "TEST1" class="red" style="font-size: 0.9em; font-family: Arial; text-indent:0.3em; ">---TEST1---</option> <option value="http://www.google.com" style="font-size: 0.9em; font-family: Arial;">GOOGLE</option> </select> <!-- WARNING: There is logic in the MM_resolveTargetUrl function above that relies on the initial values of the dropdown boxes. If the initial values ---TEST1--- and ---TEST2--- change, the if conditions in the function must be changed as well!! --> <select name="jumpMenu2" id="jumpMenu2" style="background-color:#000; width:150px; color:#CCC;"> <option selected = "TEST2" style="font-size: 0.9em; font-family: Arial;">---TEST2---</option> <option value="http://www.yahoo.com" style="font-size: 0.9em; font-family: Arial;">YAHOO</option> </select> <select name="jumpMenu3" id="jumpMenu3" style="background-color:#000; width:150px; color:#CCC;"> <option selected = "TEST3" style="font-size: 0.9em; font-family: Arial;">---TEST2---</option> <option value="http://www.yahoo.com" style="font-size: 0.9em; font-family: Arial;">YAHOO</option> </select> <input type="button" name="go_button" id= "go_button" value="Go" onClick="MM_resolveTargetUrl('jumpMenu','jumpMenu2','jumpMenu3','parent',1)" > </legend> </form> </body> </html> |