HTML ListBox

  • Thread starter Thread starter Mariame
  • Start date Start date
M

Mariame

Hi Everyone
im using an html textbox that runat server in webform1 and i send it the
value from webform2 using the following script :
Response.Write("<script>window.opener.Form1.textbox.value = '" + variable+
"' </script>")

It Works

The problem that i want to replace the html textbox with html listbox (also
runat server)so it can hold several items, so i tried this script

Response.Write("<script>window.opener.Form1.listbox1.items.add( '" +
variable+ "') </script>")

But it gives me error in script, Any idea about how to make it work?????

Thx in Adv
 
Hi,

Try this:

Response.Write("<script> AddItem('test', '0') </script>")

Then in your aspx page have this:

<script language='javascript'>
function AddItem(strText, strValue) {
listbox1.options.add(document.createElement("option"));
listbox1.options[(listbox1.options.length - 1)].text = strText;
listbox1.options[(listbox1.options.length -1 )].value = strValue;
}
</script>

Good luck! Ken.
 
Back
Top