Solved

Problem with Apperaence of dynamically populated listbox in Netscape

Posted on 2002-04-11
4
155 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
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 …
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…

914 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now