Solved

Problem with Apperaence of dynamically populated listbox in Netscape

Posted on 2002-04-11
4
160 Views
Last Modified: 2008-07-03
I am populating a drop down listbox control dynamically through a javascript function.
The drop down list box is behaving well in IE
But in netscape(4.7x) the list box after droping does not expand. instead it gives a vertical scroll bar showing just one item.

Please solve the problem at the earliest
Thanks
0
Comment
Question by:srividyakrishnamurthy
4 Comments
 
LVL 30

Expert Comment

by:third
ID: 6933362
AFAIK, this can't be done. 'twas resolved in the later versions of netscape.
0
 
LVL 1

Expert Comment

by:nagarajan75
ID: 6933573
Hi Srividya,

Here is the code the answers your question.I have implemented two  methods of doing the above.One without the function and with the function.

Hope i have answered your question.

Regards,
Nagarajan.

<html>
<head>
     <title>Untitled</title>
     <script>
     var str=new Array();
     str[0]="India";
     str[1]="US";
     str[2]="UK";
     str[3]="Australia";
     str[4]="Singapore";
     
     var strNew=new Array();
     strNew[0]="HongKong";
     strNew[1]="NewZealand";
     strNew[2]="uk";
     strNew[3]="Australia";
     strNew[4]="Singapore";
     
     function populate(f){
          for(i=0;i<str.length;i++){
             f.selectBox.options[i].text=str[i];
          }
     }
     </script>
</head>

<body >
<form name="f">
Select Box1 <select name="selectBox">
<option>-----------
<option>
<option>
<option>
<option>
<option>
</select>
<br>
Select Box2
<select >
<script>
for(i=0;i<str.length;i++){
   document.write("<option>"+str[i]);
}

</script>
</select>
<input type="button" value="POPULATE Select Box1" onclick="populate(f)" >
</form>


</body>
</html>
0
 
LVL 22

Accepted Solution

by:
CJ_S earned 300 total points
ID: 6953387
The only way to do that is to make the selectbox appear the correct size at startup and replacing the option safter that. So:

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

CJ
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 7054553
Zero response to help given, finalized and closed.
Moondancer - EE Moderator
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question