HTML ListBox

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
 
K

Ken Dopierala Jr.

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.
 

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,781
Messages
2,569,615
Members
45,294
Latest member
LandonPigo

Latest Threads

Top