You have two options with this code:

        1) Remove the  <option value="0"></option> default value.  That way a valid 
value will always be selected.
        2) Change the test in the JS function to if (theform.member_role.selectedindex 
!= 0), since the first item has an index of 0, not -1.

The select box that you have defined here will always have one (and only one) item 
selected.  If you want to allow for the selection of multiple items, you must specify 
multiple on the SELECT tag.  If you do this, then the test for a selectedindex value 
of -1 is appropriate (and you'd probably want to remove that first OPTION as well).

> -----Original Message-----
> From: paul . [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, April 18, 2001 11:56 AM
> To:   CF-Talk
> Subject:      make the select menu a must select
> 
> Hi Guys !.
> i need this select menu a must selct when i submit the form 
> atleast one item has to be selcted 
> Kindly help me
> -------------------------------------
>   <select name="member_role">
>                   <option value="0"></option>
>                   
>                   <cfoutput query=qry_get_roles> 
>                     <option 
>value="#qry_get_roles.rec_id#">#qry_get_roles.role_name#- 
>                     <cfset role_type="CA Staff">
>                     <cfif type eq 2>
>                     <cfset role_type="Support">
>                     <cfelseif type eq 3>
>                     <cfset role_type="Liaison">
>                     </cfif>
>                     #role_type#</option>
>                   </cfoutput> 
>                 </select>
>                 </font></td>
>             </tr>
>           </table>
>         </td>
>       </tr>
>     </table>
>     <p>
>       <input type="submit" name="Submit" value="Add Team Member" onclick="validate">
>     </p>
>     </div>
> --------------------------------------
> <script language ="javascript">
> function validate(theform) 
>       {
>       if(theform.member_role.selectedindex!=-1)
>       theform.submit();
>       else 
>               {alert ("Plese select");
>               }
>       }
> </script>
> 
> 
> 
> 
> -paul
>  this is the javascript i tried
> 
> 
> Get 250 color business cards for FREE!
> http://businesscards.lycos.com/vp/fastpath/
> 
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to