Thanks, by stepping through the code a little slower I was able to put most
of this to good use
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Monday, January 15, 2001 10:29 AM
Subject: RE: Javascript on selectboxes


> When two boxes are unselected, their values are the same.  Add a statement
> to make sure one of the values is also checked.
>
>
>
> For clarity's sake, I'd also rewrite the code this way.  In 6 months, you
> might have to look at this again and the more you can break it down, the
> better it will be then.  This is not the most efficient code, but
sometimes
> with complicated logic its better to write clearly and slow down those
> animated icons a little...
>
> var box1=document.updatefav.myselectbox1.value;
> var box2=document.updatefav.myselectbox2.value;
> var box3=document.updatefav.myselectbox3.value;
>
> // Next, for clarity, I'd go ahead and compute boolean values on the
> matches:
> var box12 = ( (box1==box2) && (box1 != unselectedValue) );  // box 1&2
match
> and are selected
> var box13 = ( (box1==box3) && (box1 != unselectedValue) );  // box 1&3
match
> and are selected
> var box23 = ( (box2==box3) && (box2 != unselectedValue) );  // box 2&3
match
> and are selected
>
> // Now check the values.  Logic is redundent, but left for readability
> if (box12 && box13 && box23) { //all 3 match }
> if (box12 && !box13 && !box23) {//1 and 2 match, 3 doesn't match either}
> if (!box12 && !box13 && box23) {//2 and 3 match, 1 doesn't match either)
> if (!box12 && box13 && !box23) {//1 and 3 match, 2 doesn't match either)
> if (!box12 && !box13 && !box23) {//none match)
> // There are 3 other combinations of box12, box23 and box13, but they are
> logically incosistent
> // example, box12=1, box23=1, box13=0  ==> box1=box2=box3!=box1
>
>
>
> Brian
>
> -----Original Message-----
> From: Cami Lawson [mailto:[EMAIL PROTECTED]]
> Sent: Monday, January 15, 2001 10:30 AM
> To: CF-Talk
> Subject: Javascript on selectboxes
>
>
> I have this script that is called when a form is submitted.  It is
supposed
> to display a popup window if two of the three selectboxes are the same.
It
> works good except that if the first box is selected and the other two are
> null or empty then the popup appears.  Same thing happens with the second
> box selected and the first and third null or emtpy, and the same with the
> third box.  Otherwise it works great with two boxes selected that might be
> the same.  Any ideas on where I have gone wrong with this one?
>
> TIA,
>
> cami
>
> function popup( pageToLoad, winName, width, height)
> {
> if ((document.updatefav.myselectbox.value ==
> document.updatefav.myselectbox1.value) ||
>       (document.updatefav.myselectbox.value ==
> document.updatefav.myselectbox2.value) ||
>       (document.updatefav.myselectbox1.value ==
> document.updatefav.myselectbox2.value))
>   { if ((document.updatefav.myselectbox.value == null) &&
> (document.updatefav.myselectbox1.value  == null))
>    {return true;}
>     else if
>         ((document.updatefav.myselectbox.value == null) &&
> (document.updatefav.myselectbox2.value == null))
>      {return true;}
>     else if
>      ((document.updatefav.myselectbox1.value == "") &&
> (document.updatefav.myselectbox2.value == ""))
>      {return true;}
>     else
>   {
>   xposition=200; yposition=300; width=250; height=90
>      args = "width=" + width + "," + "height=" + height + "," +
>   "location=0," + "menubar=0," + "resizable=1," + "scrollbars=0," +
>   "status=0," + "titlebar=0," + "toolbar=0," + "hotkeys=0," + "screenx=" +
>   xposition + "," + "screeny=" + yposition + "," + "left=" + xposition +
","
> +
>   "top=" + yposition;
>      window.open( "processed.htm","popup_win",args );
>
>   return false;}
>
> }}
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to