Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old February 1st, 2006, 09:02 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
multiselect detect

hi all. i want to ask how can i detect if multipleselect is selected or it is empty upon the form is submitted? thank you.

if value is empty generate the below messgae:
alert message("you must select at least one category");

Reply With Quote
  #2  
Old February 1st, 2006, 04:28 PM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to notepad
RE: multiselect detect

Code:
if (form.name.length <= 0) {
  alert ("you must select at least one category");
}

Reply With Quote
  #3  
Old February 2nd, 2006, 04:56 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: multiselect detect

i have tried everything i know but still i can't get the javascript to work. thank you for any idea or solution you can give me.

on my form the code looks like this-->>
<select multiple size="10" name='jobcategory[]'>
<?php
$job_list=array('&nbsp;Actuarial Science / Statistics','&nbsp;Advertising Client Servicing / Media Planning','&nbsp;Agriculture / Forestry / Fisheries','&nbsp;Architecture / Interior Design','&nbsp;Arts / Creative / Graphics Design','&nbsp;Aviation');
$vcnt=1;
foreach ($job_list as $job_name){
echo "<option value='$vcnt'>$job_name</option>n";
$vcnt++;
}
?>
</select>

and on the function formPreCheck(formobj){..........
}else if (document.appform.jobcategory.length <= 0){
alert("Please select at least one job category!");
//document.appform.language.focus();
return false;
}

please help.

Reply With Quote
  #4  
Old February 8th, 2006, 08:44 PM
Ethilien Ethilien is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Parker, CO, US
Posts: 69 Ethilien User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 41 sec
Reputation Power: 2
Send a message via AIM to Ethilien
RE: multiselect detect

Try using the selectedIndex property.

Change:
}else if (document.appform.jobcategory.length <= 0){
to:
}else if (document.appform.jobcategory.selectedIndex >= 0){

.length only returns the number of options in the select, not how many are selected

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > multiselect detect


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 5 hosted by Hostway
Stay green...Green IT