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
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