Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #15072

Re: Either Chrome is crazy or *I* am :(

From "Mel Smith" <med_cutout_syntel@aol.com>
Newsgroups comp.lang.javascript
Subject Re: Either Chrome is crazy or *I* am :(
Date 2012-07-16 10:14 -0600
Message-ID <a6isutF2akU1@mid.individual.net> (permalink)
References <a6efohFhqlU1@mid.individual.net> <50043740$0$6171$ba4acef3@reader.news.orange.fr>

Show all headers | View raw


Stephane said:

>
> JS :
> ====
>
> function addPlayer(x) {
> var f = document.forms['nameOfTheForm'],
>     a = f.elements['golfers'],
>     b = f.elements['players'],
>     o = new Option(a.value),
>     i = x.selectedIndex,
>     n = b.length;
> a.options[i] = a.options[+i+1];
> b.options[n] = o;
> b.selectedIndex = n;
> f=a=b=o=i=n=null;
> }
>
> HTML :
> ======
>
> <form name="nameOfTheForm">
> <select name="golfers" onchange="addPlayer(this)">
>
>
> tested Chrome, Safary and Firefox


Stephane:
    Thanks for the new method, and I'll test it later, but, in my actual 
system, I do more things than just add the member to the current player's 
list: (e.g., I perhaps remove him, replace him on the Draw table, re-color 
his background, etc, etc for 1200 lines.  and I have no difficulty adding a 
player to the player's list *IF*  execution would only arrive in the 
focusOnMemElement() with the *proper* player.

This morning, I constructed a test program  which I including below.  It is 
a 'biggie' so, if anyone wants it sent to their private email as an 
attachment please let me know:

Thanks all !

-Mel Smith

****************************
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Chrome Test</title>

<style type="text/css" media="screen">

div#imembers {
   position: absolute;
   width: 9em;
   top: 60px;
   left: 1em;
   height: 400px;
   margin-left: 0px;
   margin-right: 0px;
   overflow: auto;
   padding: 1px;
   background: yellow;
   border: 1px solid black;
}

div#iplayers {
   position: absolute;
   width: 9em;
   top: 60px;
   left: 12em;
   height: 400px;
   margin-left: 0px;
   margin-right: 0px;
   overflow: auto;
   padding: 1px;
   background: yellow;
   border: 1px solid black;
}

div#ihelp {
   position: absolute;
   width: 30em;
   top: 60px;
   left: 25em;
   height: 250px;
   margin-left: 0px;
   margin-right: 0px;
   overflow: auto;
   padding: 5px;
   border: 1px solid black;
}
</style>

<script type="text/javascript">
var memsel,memopts ;
var plrsel ;

function setFocusFields() {
// Set up global object for the Member <select> list and,
// the Player <select> list

var rootid = "imembername" ;
var rootel = document.getElementById(rootid) ;
memsel = rootel ; // save id of member <select> element
memopts = rootel.getElementsByTagName("option") ;

rootid = "iplayername"
rootel = document.getElementById("iplayername") ;
plrsel = rootel
}

function setFocusColor(el) {
el.style.background = "yellow" ;
el.style.color = "black" ;
return true ;
}

function setBlurColor(el) {
el.style.background = "yellow" ;
el.style.color = "black" ;
return true ;
}

function focusOnMemElement(el) {
   window.alert("a. typeof el="+typeof el) ;
   window.alert("b. el.value="+el.value) ;
   var selindex = memsel.selectedIndex ;
   var optel = memsel.options[selindex] ;
   if (optel.value == "X") {
      window.alert("Faulty Selection !  Please Try Again") ;
      return false ;
   }
   window.alert("c. selindex="+selindex+"  optel.value="+optel.value) ;
   /*  more error checks removed from here */

   setFocusColor(optel) ;

   var memcode = optel.value ;
   var memname = optel.text ;
   plradd(memcode,memname) ;
   return true;
}

function plradd(memcode,memname) {
// add the member to the player's list now at the end
// plrsel is the player's select object
// first make it one bigger to accommodate the next player
plrsel.size += 1 ;
var option = document.createElement("option") ;
option.text = memname ;
option.value = memcode ;
option.id = "iplr" + memcode ;
option.name = "plr" + memcode ;
try
   {
   // for IE earlier than version 8
   plrsel.add(option,plrsel.options[null]) ;
   }
catch (e)
   {
   plrsel.add(option,null) ;
   }

// now try to ensure that the latest 'add' is displayed even
// though it is off the screen

var plroptlen = plrsel.options.length ;

var plroptel = document.getElementById(option.id) ;
plroptel.scrollIntoView(false) ;
plrsel.selectedIndex=plroptlen ;

window.alert("Player Added: " + memcode+" "+memname) ;
return true ;
}

</script>
</head>

<body onload="setFocusFields();">
<div id="imembers">
<select id="imembername" style="font-size:12px;" 
onchange="focusOnMemElement(this);" size="96">
<option value="X" style="color:white;background:red;">1. Select 
Members</option>
<option value="3101">Anderson, Harry</option>
<option value="3102">Aubin, Ronald</option>
<option value="3103">Bamber, Bill</option>
<option value="3104">Beisel, Cliff</option>
<option value="3105">Bennett, Gary</option>
<option value="3193">Bennett, Nick</option>
<option value="3106">Breault, Henri</option>
<option value="3107">Breault, Ronald</option>
<option value="3108">Buchanan, Bill</option>
<option value="3190">Buchanan, Don</option>
<option value="3109">Burly, John</option>
<option value="3110">Cathcart, Chuck</option>
<option value="3111">Cheung, William</option>
<option value="3191">Cheuny, Bill</option>
<option value="3112">Chobater, Ed.</option>
<option value="3113">Corrigan, Ed.</option>
<option value="3192">Crawford, Len</option>
<option value="3114">Cutting, Cyrl</option>
<option value="3115">Darlington, Ken</option>
<option value="3117">DeJong, Jack</option>
<option value="3116">Dean, Michael</option>
<option value="3118">Denis, Paul</option>
<option value="3119">Dove, Jim</option>
<option value="3120">Draper, Mike</option>
<option value="3121">Gaudet, Maurice</option>
<option value="3122">Gerard, Mel</option>
<option value="3123">Gibson, Neil</option>
<option value="3124">Gignac, Dennis</option>
<option value="3125">Gleiberman, Norm</option>
<option value="3126">Gowin, Grant</option>
<option value="3127">Graves, David</option>
<option value="3128">Gundeson, John</option>
<option value="3129">Gust, Bill</option>
<option value="3189">Haverlock, Darryl</option>
<option value="3130">Hopkins, Ray</option>
<option value="3131">Howard, Les</option>
<option value="3132">Hurak, Jerry</option>
<option value="3133">Itterman, Nelson</option>
<option value="3134">Johnson, Peter</option>
<option value="3135">Kasha, Ron</option>
<option value="3136">Killian, Roy</option>
<option value="3137">Kitt, Steve</option>
<option value="3138">Kruger, Merv</option>
<option value="3139">Kwasnycia, Nick</option>
<option value="3140">Lavers, Jim</option>
<option value="3141">Lavoie, Leon</option>
<option value="3142">Leggatt, Dick</option>
<option value="3143">Lehoday, Michel</option>
<option value="3144">MacKay, Malcolm</option>
<option value="3145">MacPherson, Fred</option>
<option value="3146">Magnan, Gerry</option>
<option value="3147">Maguire, Jack</option>
<option value="3148">Mah, Bill</option>
<option value="3149">Mathieu, Rene</option>
<option value="3150">McCarthy, Doug</option>
<option value="3151">McCormack, Vern</option>
<option value="3152">McKenzie, John</option>
<option value="3153">Mead, Glenn</option>
<option value="3154">Mitchell, Norm</option>
<option value="3155">Murphy, Terry</option>
<option value="3156">Musteca, Ed.</option>
<option value="3157">Nikolai, Helmut</option>
<option value="3158">Orr, Stewart</option>
<option value="3159">Paquette, Ray</option>
<option value="3160">Parker, Dave</option>
<option value="3161">Peterson, Gordon</option>
<option value="3162">Phare, Cal</option>
<option value="3163">Poon, Henry</option>
<option value="3164">Proche, Tony</option>
<option value="3165">Pshyk, Robert</option>
<option value="3166">Rakochey, Ernie</option>
<option value="3167">Ready, Johl</option>
<option value="3168">Reddekopp, Ron</option>
<option value="3169">Rhind, Cliff</option>
<option value="3170">Ritson-Bennett, Nick</option>
<option value="3171">Savard, John</option>
<option value="3172">Savard, Pierre</option>
<option value="3173">Savard, Venant</option>
<option value="3174">Schaefenacker, Kurt</option>
<option value="3175">Schlesinger, Gerhard</option>
<option value="3176">Smith, Mel</option>
<option value="3195">Southwood, Vic</option>
<option value="3177">Stokowski, Bob</option>
<option value="3178">Stollery, Tom</option>
<option value="3179">Strong, Norman</option>
<option value="3180">Swan, Jim</option>
<option value="3181">Thillefer, Robert</option>
<option value="3194">Turner, Don</option>
<option value="3182">Vance, Hubie</option>
<option value="3183">Vincent, Georges</option>
<option value="3184">Weber, Orlan</option>
<option value="3185">Westlund, Glen</option>
<option value="3186">Wilson, Roger</option>
<option value="3187">Witten, Larry</option>
<option value="3188">Yoon, John</option>
</select>
</div>
<div id="iplayers">
<select id="iplayername" style="font-size:12px;overflow:scroll;" 
onchange="focusOnPlrElement(this);" size="1">
   <option value="X" style="color:white;background:red;">2. Select 
Players</option>
</select>
</div>
<div id="ihelp">
<span style="text-decoration:underline;font-weight:bold;">How to Show the 
Difference between FF/IE and Chrome/Safari:</span><br /><br />
1. Using FF or IE, select a person near the *bottom* of<br />
&nbsp;&nbsp;&nbsp;the List of Members and click on him.<br /><br />
2. Watch as that person is added to the bottom of the Player's List.<br 
/><br />
3. Try the same thing with Chrome or Safari, and watch as a<br />
&nbsp;&nbsp;&nbsp;totally *different* person is 'selected'.<br /><br />
4. How can I make Chrome, FF, IE &amp; Safari browsers work the same way ??
</div>
</body>
</html>
****************************



Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Either Chrome is crazy or *I* am :( "Mel Smith" <med_cutout_syntel@aol.com> - 2012-07-14 18:04 -0600
  Re: Either Chrome is crazy or *I* am :( Jeff North <jnorthau@yahoo.com.au> - 2012-07-15 13:29 +1000
    Re: Either Chrome is crazy or *I* am :( "Mel Smith" <med_cutout_syntel@aol.com> - 2012-07-14 22:31 -0600
      Re: Either Chrome is crazy or *I* am :( "Mel Smith" <med_cutout_syntel@aol.com> - 2012-07-15 10:05 -0600
        Re: Either Chrome is crazy or *I* am :( Matt McDonald <matt@fortybelow.ca> - 2012-07-15 10:48 -0600
          Re: Either Chrome is crazy or *I* am :( "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-07-15 17:05 +0000
            Re: Either Chrome is crazy or *I* am :( "Mel Smith" <med_cutout_syntel@aol.com> - 2012-07-15 12:49 -0600
          Re: Either Chrome is crazy or *I* am :( "Mel Smith" <med_cutout_syntel@aol.com> - 2012-07-15 12:41 -0600
  Re: Either Chrome is crazy or *I* am :( SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-07-16 17:46 +0200
    Re: Either Chrome is crazy or *I* am :( "Mel Smith" <med_cutout_syntel@aol.com> - 2012-07-16 10:14 -0600
      Re: Either Chrome is crazy or *I* am :( Christoph Becker <cmbecker69@gmx.de> - 2012-07-16 19:31 +0200
        Re: Either Chrome is crazy or *I* am :( "Mel Smith" <med_cutout_syntel@aol.com> - 2012-07-16 12:21 -0600
          Re: Either Chrome is crazy or *I* am :( Christoph Becker <cmbecker69@gmx.de> - 2012-07-16 20:44 +0200
            Re: Either Chrome is crazy or *I* am :( "Mel Smith" <med_cutout_syntel@aol.com> - 2012-07-16 15:07 -0600
      Re: Either Chrome is crazy or *I* am :( SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-07-17 01:47 +0200
        Re: Either Chrome is crazy or *I* am :( "Mel Smith" <med_cutout_syntel@aol.com> - 2012-07-30 13:31 -0600

csiph-web