That'll only validate after submission; if you move exactly the same logic
to an onChange on the select box; you can do real-time validate, and
actually not allow more than required. If that's what you want of course!


-----Original Message-----
From: Rich Wild [mailto:[EMAIL PROTECTED]
Sent: 15 July 2003 13:10
To: '[EMAIL PROTECTED]'
Subject: RE: [ cf-dev ] JS : Get Selected Options


<form name="myForm" onsubmit="countSels();return false;">
<select name="mySelectBox" size="5" multiple>
<option value=1>a</option>
<option value=2>b</option>
<option value=3>c</option>
<option value=4>d</option>
<option value=5>e</option>
</select>
<input type="submit">
</form>

<script>
        function countSels() {
                var selCount = 0;
                with (document.myForm) {
                        for (var i=0;i < mySelectBox.options.length;i++) {
                                if (mySelectBox.options[i].selected) {
                                        selCount++;
                                }
                        }
                }
                alert('Number of Options Selected: ' + selCount);
        }
</script>

> -----Original Message-----
> From: Robertson-Ravo, Neil (RX)
> [mailto:[EMAIL PROTECTED]
> Sent: 15 July 2003 12:58
> To: '[EMAIL PROTECTED]'
> Subject: [ cf-dev ] JS : Get Selected Options
> 
> 
> I can't remember this at all....on a multi-select box, I need 
> to limit the
> amount of options checked  - well all I want to do is check 
> them on a button
> click.
> 
> How do you get the count of whats selected in a multi-select 
> box (where the
> user has used ctrl-click to get the count)?
> 
> uurgh
> 
> 
> -- 
> ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
> 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> For human help, e-mail: [EMAIL PROTECTED]
> 


-- 
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]
DISCLAIMER: This e-mail is confidential and may also be legally privileged.
If you are not the intended recipient, use of the information contained in
this e-mail (including disclosure, copying or distribution) is prohibited
and may be unlawful.  Please inform the sender and delete the message
immediately from your system.  This e-mail is attributed to the sender and
may not necessarily reflect the views of the patsystems Group and no member
of the patsystems Group accepts any liability for any action taken in
reliance on the contents of this e-mail (other than where it has a legal or
regulatory obligation to do so) or for the consequences of any computer
viruses which may have been transmitted by this e-mail. The patsystems Group
comprises patsystems plc and its subsidiary group of companies.

-- 
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]

Reply via email to