HtmlSelect control is not helping and client side coding became a real headache

S

Suhail A, Salman

Dear All,

I placed a HtmlSelect control on a web page and set "Run at Server", the
objective of this list box is that the client adds all his accounts to this
text box, and because this is a client side operation / no server
intervention is required, I wrote the JavaScript below to add account number
entered in a text box to the list control, this works fine, the client can
enter all his accounts to the html select control, the problem is that when
the page is posted to the server the code within the server returns no items
within the control so I have lstCustAcc.Items.Count = 0 even on the page it
contains some thing else >0, and I could not access any item within the
control.

PLEASE HELP.


function AddAcc()
{
var lstLen = document.Form1.lstCustAcc.length;
var selectedText = document.Form1.txtAccountNo.value;
var selectedValue = document.Form1.txtAccountNo.value;
var i;
var isNew = true;

if (lstLen != 0)
{
for (i = 0; i < lstLen; i++)
{
thisitem = document.Form1.lstCustAcc.options.text;
if (thisitem == selectedText)
{
isNew = false;
break;
}
}
}
if (isNew)
{
newoption = new Option(selectedText, selectedValue, false, false);
document.Form1.lstCustAcc.options[lstLen] = newoption;
}
document.Form1.lstCustAcc.selectedIndex=-1;
}





Thanks in advance,
Suhail
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top