Re: [PHPLIB] oohforms: select multiple and js validation From: Bob Strouper (bobw123 <email protected>)
Date: 10/31/99

Hello,

Well as far as I can tell the javascript DOM does not
like <form> element names with []...it must think that
it's an array.

So the only way I could test against the multiple select
<form> element with names that included [] was to test
them by numerical index.

But since my form elements will be changing position I had to
come up with the following code that checks the name of
each element then counts the options based on that name.
If anyone could reccomend a better method, please let
me know.

Thanks,
Bob

PS: mail.com will remove most of my formatting from the
code below :-/

$after = "for (var i = 0; i < f.elements.length; i++)
{
my_el_name = f.elements[i].name
if (my_el_name == 'CARS[]' || my_el_name == 'BIKES[]')
{
num_selected = 0
for ( opt_cnt = 0; opt_cnt < f.elements[i].options.length; opt_cnt++)
{
if (f.elements[i].options[opt_cnt].selected==true)
num_selected++
}
if ( num_selected < 1 )
{
alert(\"Please enter at least one \" + my_el_name)
return(false)
break
}
}
}
";

$f->finish($after);

##############################################

Bob Strouper wrote:

> Hello,
>
> Would anyone have an example of how I could validate
> ( client side / javascript ) multiple select form elements
> using oohforms?
>
> All I would like is to validate that at least one element
> from the multiple select dropdown has been selected.
>
> Thank you,
> Bob
>

__________________________________________________
FREE Email for ALL! Sign up at http://www.mail.com

-
PHP3 Base Library Mailing List. Send messages to <phplib <email protected>>.
To unsubscribe, send "unsubscribe" to <phplib-request <email protected>> in
the body, not the subject, of your message.