467,224 Members | 1,333 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,224 developers. It's quick & easy.

accessing webforms-listbox from clientside jscript

Hello together,

I wanted to ask if somebody can help me with accessing a listbox (a
serverside webform from the designer-toolbox) from clientside JScript. I need
to add and remove values and find out about the selected index.

I hope somebody can help & thanks in advance

RFS666

Nov 20 '05 #1
  • viewed: 1267
Share:
1 Reply
To add a value (listitem):
var list = document.getElementById ("ListBox1");
if (list)
{
alert("selected Index= " + list.selectedIndex;
var option= document.createElement ("option");
list.options.appendChild(option);
var txt = document.getElementById ("txtListItem");
option.text=txt.value;
}

The ListBox server control renders an HTML select object on the browser. To
manipulate it using JScript (or Javascript) use the options collection of the
HTML SELECT object. There is a "remove" method for the options collection.

For a sample on managing the viewstate of ListBox server control on the
browser: http://www.societopia.net/samples/li...lientside.aspx
--
[note: if this post answers your question, you can mark it as an answer
using the web-based newsreader functions]
-----
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"RFS666" wrote:
Hello together,

I wanted to ask if somebody can help me with accessing a listbox (a
serverside webform from the designer-toolbox) from clientside JScript. I need
to add and remove values and find out about the selected index.

I hope somebody can help & thanks in advance

RFS666

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Salek Talangi | last post: by
1 post views Thread by Paul R | last post: by
3 posts views Thread by | last post: by
20 posts views Thread by Martin Rosén-Lidholm | last post: by
2 posts views Thread by Piotr Karwatka | last post: by
4 posts views Thread by 3Cooks | last post: by
5 posts views Thread by Bit byte | last post: by
reply views Thread by JM | last post: by
reply views Thread by Adict | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.