Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Arrays and selects

Reply
Thread Tools

Arrays and selects

 
 
Mike
Guest
Posts: n/a
 
      08-19-2004
Hi all,

How do I set this to "disabled":

<select name="awards[]" multiple size="6">
<option value="1">Award 1</option>
<option value="2">Award 2</option>
<option value="3">Award 3</option>
<option value="4">Award 4</option>
</select>

I don't know how many options there will be as they are fed from a DB.

Thanks very, very much in advance.

Mike
 
Reply With Quote
 
 
 
 
Michael Winter
Guest
Posts: n/a
 
      08-19-2004
On 19 Aug 2004 14:21:42 -0700, Mike <(E-Mail Removed)> wrote:

> How do I set this to "disabled":


When you say, "this", to what are you referring? The whole SELECT element,
or just some (or all) of the OPTIONS?

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
 
Reply With Quote
 
 
 
 
Grant Wagner
Guest
Posts: n/a
 
      08-20-2004
Mike wrote:

> Hi all,
>
> How do I set this to "disabled":
>
> <select name="awards[]" multiple size="6">
> <option value="1">Award 1</option>
> <option value="2">Award 2</option>
> <option value="3">Award 3</option>
> <option value="4">Award 4</option>
> </select>
>
> I don't know how many options there will be as they are fed from a DB.
>
> Thanks very, very much in advance.
>
> Mike


document.forms['yourFormName'].elements['awards[]'].disabled = true;

If you are calling this from someplace on the form, say a button, and you
already have a reference to the form, you could do something like:

<input type="button"
value="Toggle Awards"
onclick="this.form.elements['awards[]'].disabled =
!this.form.elements['awards[]'].disabled;"
>


A shorter form when toggling might be:

this.form.elements['awards[]'].disabled ^= true;

No guarantees it'll work since it turns the result into a number and
assigning 0 or 1 to disabled may not work - although they should be type
converted to a boolean - 0 being false, 1 being true. You'll have to test
it to see if it works (assuming toggling the disabled property is what you
want to do).

--
Grant Wagner <(E-Mail Removed)>
comp.lang.javascript FAQ - http://jibbering.com/faq

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Python library for generating SQL queries [selects, alters,inserts and commits] Alec Taylor Python 5 10-15-2011 02:44 AM
Multidimensional arrays and arrays of arrays Philipp Java 21 01-20-2009 08:33 AM
University of Minnesota Selects Cisco Storage Area Network for Scalability, Reliability technology_post@yahoo.com Cisco 0 03-30-2006 05:37 PM
single threaded application, that selects between stdin and a listeningsocket. Klaus C Programming 1 12-09-2004 12:43 PM
Datalist selects Item after first click, but does apply the SelectedItemTemplate after the second click only Dirk Meusel ASP .Net 1 08-19-2003 09:56 AM



Advertisments