Solved

Problem with Apperaence of dynamically populated listbox in Netscape

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

744 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

11 Experts available now in Live!

Get 1:1 Help Now