Click to See Complete Forum and Search --> : How check if a menulist Multiple form have been selected??


turb
11-26-2003, 11:19 AM
Hi!,

i've got a form that contain a menulist:

<script language="JavaScript">
function checkFill(){
if (document.remove.Rem[].value == "") {
alert("Vous devez sélectionner au moin un UTILISATEUR!")
document.remove.Rem[].focus()
return false}
}
</script>
<form name="remove" action="update.php method="post" onSubmit="return checkFill()">
<select name="Rem[]" size="5" multiple class="menu">
...
</select>
</form>

but it seem that i can't check if the visitor have selected one/multiple value so if the user click on submit, it cause an page error

gil davis
11-26-2003, 12:16 PM
Then do not specify "MULTIPLE" in the select tag.

To check to see if multiple options are selected, you must look at each option and test the SELECTED property of the option. The property "selectedIndex" of the SELECT object will not be valid.

turb
11-26-2003, 12:47 PM
I have to dynamically my menulist with php so, i don't know how many value the list will have AND i don't know how many value the user will select; he can select one or multiple value.

What can i do?