JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 6th, 2005, 03:04 PM
m00nbeast m00nbeast is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 9 m00nbeast User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 24 m 35 sec
Reputation Power: 0
How do i select all the values in a dynamically generated select box(multiple)

How do i select all the values in a dynamically generated select box(multiple) on submit?
--------------------------------------------------------------------------------
Im Sorry if this has been addressed before. I couldnt find an asnwer.

I am allowing the site user to populate a multi select box with email addresses. I want to be able to select all the values in the multi select on form submit, because I can't expect the user to do so. Is there a javascript function that I can use to accomplish this?

Thanks for your time and help good people


Reply With Quote
  #2  
Old May 6th, 2005, 04:46 PM
ChiefWigs1982's Avatar
ChiefWigs1982 ChiefWigs1982 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Location: I have emerged from the place of spells and fairies
Posts: 97 ChiefWigs1982 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 17 h 35 m 12 sec
Reputation Power: 4
You also can't rely on the user having JavaScript enabled on his/her
machine, in which case, your form will never get filled in properly.

Do this on the server instead.

Reply With Quote
  #3  
Old May 7th, 2005, 08:32 PM
Kravvitz Kravvitz is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2005
Location: USA
Posts: 134 Kravvitz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 h 38 m 30 sec
Reputation Power: 4
Why don't you store the email addresses in a textarea or hidden input instead?

Reply With Quote
  #4  
Old May 27th, 2005, 03:10 AM
grotgod grotgod is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 3 grotgod User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 8 sec
Reputation Power: 0
Loop through the multiple select element

I would suggest that you simply loop through the multiple select element and set their selected attribute to true:
function loop_select() { for(i=0;i<=document.your_form.name_of_element.length-1;i++) { document.your_form.name_of_element.options[i].selected = true; } }

Simple as that.

You could also go all fuzzy and nice by defining an array or even an object that could be invoked and changed by an event listener attached to the textfield (I presume) where the user initially states the values that populate the multiple select element. Then simply assign this stringefied array to the value of a hidden field prior to submission. Yes, that would be nice.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > How do i select all the values in a dynamically generated select box(multiple)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway