Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Javascript] Limit Choices in Multiple Select Box


  • From: javascript@xxxxxxxxxx (Terry)
  • Subject: [Javascript] Limit Choices in Multiple Select Box
  • Date: Thu, 12 Dec 2002 09:35:34 -0500

This is a multi-part message in MIME format.

------=_NextPart_000_006F_01C2A1C1.D24A4D00
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

sure...  i have done it before...  i dont have the code but you will =
want to look into doing the following...

-new array to hold current values of selected indexs (HOLDER)

-select.onchange will evoke your function to check

-onchange function:
     check length of  HOLDER
    if > 3 then
            loop select and reset values to unselect   =20
            loop HOLDER set select.options[HOLDER].selected to true
    else
            loop select and insert selected indexes into HOLDER



Anyway, this is where I would start....  I would recommend getting =
O'Reilly's Javascript - The Definitive Guide

~ Terry
757 581-5981
AIM/Yahoo: lv2bounce


----- Original Message -----=20
From: "David Hannum" <hannum@xxxxxxxx>
To: <javascript@xxxxxxxxxx>
Sent: Thursday, December 12, 2002 7:52 AM
Subject: [Javascript] Limit Choices in Multiple Select Box


> I'm using a script that when a user selects an option in a =
multi-select box,
> it places it in another box.  What I need to do is limit the number of =
items
> in the second box to three.  Can this be done?
>=20
> Dave
>=20
>=20
>=20
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D
> David R. Hannum
> Web Analyst/Programmer
> Ohio University Computer Services
> Administrative Systems
> (740) 597-2524
>=20
> "If your wife is having fun, and you're not . . .
> You're still having a lot more fun than if
> you're having fun, and she's not!"  (Red Green)
>=20
> _______________________________________________
> Javascript mailing list
> Javascript@xxxxxxxxxx
> https://lists.LaTech.edu/mailman/listinfo/javascript
>=20
>=20

------=_NextPart_000_006F_01C2A1C1.D24A4D00
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2722.900" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>sure...&nbsp; i have done it =
before...&nbsp; i dont=20
have the code but you will want to look into doing the =
following...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>-new array to hold current&nbsp;values =
of selected=20
indexs (HOLDER)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>-select.onchange will evoke your =
function to=20
check</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>-onchange function:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;&nbsp; =
check&nbsp;length=20
of&nbsp;&nbsp;HOLDER</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; if &gt; 3 =
then</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; loop select and reset values to =
unselect&nbsp;&nbsp;&nbsp;=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; loop HOLDER set select.options[HOLDER].selected to=20
true</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; else</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; loop select and&nbsp;insert selected indexes into=20
HOLDER</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Anyway, this is where I would =
start....&nbsp; I=20
would recommend getting O'Reilly's Javascript - The Definitive=20
Guide</FONT></DIV>
<DIV><BR><FONT face=3DArial size=3D2>~ Terry<BR>757 =
581-5981<BR>AIM/Yahoo:=20
lv2bounce</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>----- Original Message ----- </FONT>
<DIV><FONT face=3DArial size=3D2>From: "David Hannum" &lt;</FONT><A=20
href=3D"mailto:hannum@xxxxxxxx";><FONT face=3DArial=20
size=3D2>hannum@xxxxxxxx</FONT></A><FONT face=3DArial =
size=3D2>&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>To: &lt;</FONT><A=20
href=3D"mailto:javascript@xxxxxxxxxx";><FONT face=3DArial=20
size=3D2>javascript@xxxxxxxxxx</FONT></A><FONT face=3DArial =
size=3D2>&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Sent: Thursday, December 12, 2002 7:52=20
AM</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Subject: [Javascript] Limit Choices in =
Multiple=20
Select Box</FONT></DIV></DIV>
<DIV><FONT face=3DArial><BR><FONT size=3D2></FONT></FONT></DIV><FONT =
face=3DArial=20
size=3D2>&gt; I'm using a script that when a user selects an option in a =

multi-select box,<BR>&gt; it places it in another box.&nbsp; What I need =
to do=20
is limit the number of items<BR>&gt; in the second box to three.&nbsp; =
Can this=20
be done?<BR>&gt; <BR>&gt; Dave<BR>&gt; <BR>&gt; <BR>&gt; <BR>&gt;=20
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D<BR>&gt; David R. Hannum<BR>&gt; Web=20
Analyst/Programmer<BR>&gt; Ohio University Computer Services<BR>&gt;=20
Administrative Systems<BR>&gt; (740) 597-2524<BR>&gt; <BR>&gt; "If your =
wife is=20
having fun, and you're not . . .<BR>&gt; You're still having a lot more =
fun than=20
if<BR>&gt; you're having fun, and she's not!"&nbsp; (Red Green)<BR>&gt; =
<BR>&gt;=20
_______________________________________________<BR>&gt; Javascript =
mailing=20
list<BR>&gt; </FONT><A href=3D"mailto:Javascript@xxxxxxxxxx";><FONT =
face=3DArial=20
size=3D2>Javascript@xxxxxxxxxx</FONT></A><BR><FONT face=3DArial =
size=3D2>&gt;=20
</FONT><A =
href=3D"https://lists.LaTech.edu/mailman/listinfo/javascript";><FONT=20
face=3DArial=20
size=3D2>https://lists.LaTech.edu/mailman/listinfo/javascript</FONT></A><=
BR><FONT=20
face=3DArial size=3D2>&gt; <BR>&gt; </FONT></BODY></HTML>

------=_NextPart_000_006F_01C2A1C1.D24A4D00--