473,385 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

RE: Dynamically populating a drop down list.

Hi Folks,

I have designed a dynamic drop down list but having problems since it is not working as intended. Please help

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <Script language="Javascript">
  4.  
  5. var Select = new Array("-----");
  6.  
  7. var test = (
  8. "Select",
  9. "ITEM 1",
  10. "ITEM 2",
  11. "ITEM 3",
  12. "ITEM 4");
  13.  
  14. var test 1("Select",
  15. "Product 1",
  16. "Product 2",
  17. "Product 3",
  18. "Product 4");
  19.  
  20. function swap(the_array_name)
  21. {
  22. var numbers_select = window.document.Formname.Product;
  23. var the_array = eval(the_array_name);
  24. setOptionText(window.document.Formname.Product,the_array);
  25. }
  26.  
  27. function setOptionText(the_select, the_array)
  28. {
  29. var c;
  30. the_select.length=the_array.length;
  31. for (c=0; c < the_array.length; c++)
  32.     {
  33.     the_select.options[c].text = the_array[c];
  34.     }
  35. }
  36. </script>
  37. <form name="Formname">
  38. <tr><td>
  39. <select name="item" onchange="swap(window.document.Formname.item.options[selectedIndex].value);">
  40. <option value="1">Test</option>
  41. <option value="2">Test 1</option>
  42. </select>
  43.  
  44. <select name="Product">
  45. <option selected>Select</option>
  46. </select>
  47. </form>
  48. </html>
  49. <form name
The above is the rough code like what i am trying to achieve. Please help me with this subject.

Thanks in advance!!

Chandhseke
Dec 11 '09 #1
1 2179
Dormilich
8,658 Expert Mod 8TB
how to define an Array.
Dec 12 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Gurry | last post by:
Hi there I would like to write a javascript function that creates a drop-down list dynamically. I read on the docs that most HTML controls can not be created on run-time. what kind of...
5
by: TB | last post by:
Hi All: The following is probably a newbie question, but please bear with me: I am populating a drop down list with items from a database, and would the default selected item to be the current...
4
by: Pete Lux | last post by:
I have a drop down that populates on page load. The drop down brings in customer numbers from my local MSDE database. It does this fine, but I click a button that finds quotes for those customers...
2
by: Jim in Arizona | last post by:
My goal, somehow, is to populate a dropdownlist with all the user names in active directory. I don't even know where to begin, really. I added a reference to System.DirectoryServices so I could...
4
by: bryan | last post by:
Hi all, I am working on a .net 2.0 web app. On page load I display a gridview with a drop down list (Employees), when the user selects from the drop down list, the grid view is filled with...
3
by: Yi Chen | last post by:
We have a drop down list on a PHP page, with several product names, and when people click one item, we will refresh the same page with the product name as parameter, and in turn we want to include...
6
by: Rob Meade | last post by:
Hi all, Looking for a bit of help if possible. For about 2 weeks now I've been investigating the best way to populate related drop down menus, and have their values pre-populated again if the...
3
by: DaveRook | last post by:
Hi I am using C# and Access databse for a web site. I have a drop down list which I need to populate dynamically according to results in a database. Example There will be 1 drop down list...
14
by: Philth | last post by:
Hi there, I've essentially got a form with several drop down, each populated by columns in various tables. The populating bit works fine - the column rows appear as they should in the menu. ...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.