Re: Javascript Question

by "Cyanide _7" <leo7278(at)hotmail.com>

 Date:  Thu, 01 Jun 2000 18:30:38 CDT
 To:  srushing(at)wfubmc.edu
 Cc:  hwg-languages(at)hwg.org
  todo: View Thread, Original
hi scott,
  Netscape only creates the menu once. because its content is so static, it 
cannot resize an element like IE because it can't move the text beside it. 
what you can do is reserve the space for the menu and load the original 
values. unfourtunately this must be done in both dimensions:

<select>
  <option>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </option>
  <option> </option>
  <option> </option>
  <option> </option>
  <option> </option>
  <option> </option>
  <option> </option>
<select>

you need to have spaces extend to the width of the option (use trial and 
error) and the number of options down will be the max number of visible 
options when pulled down without scrolling being necessary (again, trial and 
error will explain better). the only positive part of this workaround, is IE 
can go through the same process without difficulty, so you dont even need to 
browser sniff. good luck - Cyanide_7


>
>Hi folks,
>
>Below is a portion of code we're trying to use thats working in IE but
>not NS.  The idea here is that a person will have two select boxes, and
>based on the choice made in the first, the second select box will get
>re-loaded with new values.  The problem is that in NS, it does not
>"resize" the select box so items get truncated.  In IE, it "refreshs"
>the box and does fine. We tried using calling history.go(0) but that
>didn't work either.  But what was wierd is that to prove we were getting
>into that section of code we placed an Alert box to display  a value
>just so we could see that section execute.  Upon clikc OK in teh alert
>box, it refreshed the window and worked!  But with out the select box it
>doesn't.
>
>Any ideas?
>Thanks.
>
>Code below:
>
>function addToList(fromList, toList) {
>   var fromListLength = fromList.length
>   for (var i = 0; i < fromListLength; i++) {
>     if (fromList.options[i].selected == true) {
>   // check for no items in list - marked by default value of 0
>    if (fromList.options[i].value == 0) {
>      break
>    }
>    var toListLength = toList.length
>    // use this for one static list sending only the values you choose to
>another list
>     var isFound = false
>       for (var x = 0; x < toListLength; x++) {
>      if (toList.options[x].text == fromList.options[i].text) {
>     isFound = true
>   }
>   // get rid of default value
>      if (toList.options[x].value == 0) {
>     toList.options[x] = null
>     toListLength--
>   }
>    }
>   // add to receiving list
>    if (isFound == false) {
>      toList.options[toListLength] = new Option(fromList.options[i])
>      toList.options[toListLength].value = fromList.options[i].value
>      toList.options[toListLength].text = fromList.options[i].text
>    }
>  }
>   }
>   // use this to remove any chosen values from the sending list
>   synchList(fromList, toList)
>   if (navigator.appName == 'Netscape'){
>     history.go(0)
>     alert("refresh")
>   }
>}
>
>function synchList(fromList, toList) {
>   var fromListLength = fromList.length
>   for (var x = 0; x < fromListLength; x++) {
>     var toListLength = toList.length
>     for (var i = 0; i < toListLength; i++) {
>       if (fromList.options[x].text == toList.options[i].text) {
>      fromList.options[x] = null
>   fromListLength--
>   x--
>    }
>  }
>   }
>   if (fromList.length == 0) {
>     fromList.options[0] = new Option("....No Items
>Available....","0",false,false)
>   }
>}

________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA