Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/04/2005, 20:40
Avatar de Galled
Galled
 
Fecha de Ingreso: marzo-2005
Ubicación: Lima
Mensajes: 254
Antigüedad: 19 años, 11 meses
Puntos: 0
PHP y Javascrip en un SELECT MULTIPLE

Tengo un Select Multiple en un Html de la siguiente manera:

.....
<SCRIPT language=Javascript src="DGPA_stat_archivos/form_xsl.js"
type=text/javascript> </SCRIPT>
</head>

<body>
<div>
<FORM name=Form onsubmit="return valid_form(this)" action="salida.php" method="post">
<select multiple size="8" name="Areas[]">
.....

Pero cuando envio el submit yo quiero que me salga un mensaje que evite que envie el submit sin haber elegido nada del select. No se mucho de javascript y encontre esto en internet
....
function valid_form(theForm)
{

var there_is_some_value = false;

if (clickedMacroPanel == "true")
{
return true;
}

for (i=0; i < theForm.Areas.length; i++)
{
if (theForm.Areas.options[i].selected)
{
there_is_some_value = "true";
break;
}
}

if (!there_is_some_value)
{
alert('Por favor elija por lo menos un Departamento');
theForm.Areas.focus();
return false;
}

there_is_some_value = false;
....
PERO ME SIRVE SOLO CUANDO TENGO:
.....
<SCRIPT language=Javascript src="DGPA_stat_archivos/form_xsl.js"
type=text/javascript> </SCRIPT>
</head>

<body>
<div>
<FORM name=Form onsubmit="return valid_form(this)" action="salida.php" method="post">
<select multiple size="8" name="Areas">

Alguien me puede ayudar??