473,326 Members | 2,110 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,326 software developers and data experts.

how to add items to a list box dynamically

3
how to add items to a list box dynamically , in the mean that the contents of the list box will be changed and new things may need to be added ........
plz help how we can do that ....
Mar 5 '07 #1
4 9362
sumittyagi
202 Expert 100+
You need to study Document Object Model for that.

there are a lot of DOM manipulation functions you can use. you can manipulate DOM in any way you want.

for your case. suppose, you gave an id "dynamic_list" to you list.
then get the element by id.
var dlist = document.getElementById("dynamic_list");

then, either use innerHTML property or use createElement function to create li element.
then add that element to the list by using appendChild or insertBefore function.

I would suggest to search out for the functioning of the following functions:-
document.getElementById(id);
elemRef.appendChild(childRef);
elemRef.removeChild(childRef);
elemRef.insertBefore(oldChildRef, newChildRef);
document.createElement(tagName);
document.createTextNode(text);

in addition search out for some properties
elemRef.firstChild
elemRef.lastChild
elemRef.childNodes (it is an array)
elementRef.parent (parent of the elemRef element).

Knowing these properties and methods you can manipulate DOM easily.
Mar 5 '07 #2
acoder
16,027 Expert Mod 8TB
Sumit, I think he means a select list box not a list on a page (but I may be wrong). nag9s, check out this page for dynamic options.
Mar 5 '07 #3
If you are using JSP as ur Sercerside technology,
U can dynamically add coloumns from ur table to the select box.
It is quite easy.

What u have to dod is to implement a db connection.,
In a While loop,till the Resultset items ends,

Store the purticular coloumn in a variable.

Assign it to the value property of select box.

It will work

Regards

Shyju
Mar 5 '07 #4
nag9s
3
i got it ..... thanks for all those ....
Mar 5 '07 #5

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

Similar topics

8
by: Charlotte Henkle | last post by:
Hello; I'm pondering how to count the number of times an item appears in total in a nested list. For example: myList=,,] I'd like to know that a appeared three times, and b appeared twice,...
7
by: juglesh | last post by:
Hello, I would like to be able to have the user sort a list of items similarly to the way you sort your queue on Netflix.com. (the numbers dont change dynamically on netflix, they must be doing...
2
by: Milsnips | last post by:
hi there, i have the following HTML code: -------------------------- <asp:DropDownList id="hddList" runat="server"> <asp:ListItem Value="1">Item 1</asp:ListItem> <asp:ListItem Value="2">Item...
2
by: echan8 | last post by:
I have a dropdown list in a datagrid which I am dynamically adding items to with JavaScript. When I try to access the value of the dropdown list on postback, there is no value. The value is...
1
by: bill | last post by:
I need to be able to dynamically add items to a <asp:listbox> (or HTML <select runat=server>) using clientside javascript, and retrieve the items when the page is posted back. I use this code to...
1
by: Macca | last post by:
Hi, My app populates a list of custom objects from data fetched from a database. What i want to do now is filter the list and remove items from the list that don't match the filter criteria. ...
0
by: jeremy | last post by:
Had a tough time figuring this one out and couldn't find a good solution, so I thought I would post this and hopefully it will help someone out. When using DataBind to dynamically bind a list to...
2
by: Miesha.James | last post by:
Hi, I have a list view that will be update dynamically when new information is received. I parse through the information and call the update function to clear the current items that are in the...
0
by: Jason Hartsoe | last post by:
i've tried to add an onchange event to my checkboxes(created dynamically) chkboxlist.attributes.add("onchange", "dothat();") but it renders the onchange to the table it creates and not to the...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.