RE: [PHP-DEV] javascript not working with php
| From: | Ford, Mike [LSS] | Date: | Tue, 11 Jun 2002 15:38:06 +0000 |
| Subject: | RE: [PHP-DEV] javascript not working with php | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-85138@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Anil Garg [mailto:anilg@niksun.com]
> Sent: 11 June 2002 15:01
>
> Hi,
> In a form i have two elements:
>
> I
> <input type="text" name="name" size=25 value="test">
>
> II
> <select name="categories[]" multiple size=10>
> <? option value = ...?>....
> <? option value = ....?>....
>
> Now i want to show an alert message(using javascript) if the
> text field is
> empty or no option is selected from categories list.
>
> For the text field its working fine as below (the javascript
> method called
> when onsubmit method is called):
>
> if(theForm.name.value==""){
> alert("You must enter a Title.");
> theForm.name.focus();
> return(false);
> }
>
> But for the options list(categories) i have tried my best
> but i couldnt get
> it work.
if (theForm["categories[]"].value==""){
... no category selected ...
}
This is standard JavaScript: x["y"] is by definition equivalent to x.y
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211