Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update textarea from listboxes

Status
Not open for further replies.

moley

IS-IT--Management
Mar 26, 2002
95
GB
Hi,

I'm trying to updated a textarea with listbx value evrytime a listbox is changed. I can do this only if i hardcode the name of the listbox,(document.form.cboBox), but how do I do this with out hardcoding as I'm creating listboxes on the fly.
I'm reletively new to this so its probably really obvious.

Any help would be appreciated.

Cheers
 

Well - you have to have some way of referencing the listbox - otherwise how would JavaScript know where to obtain the values?

If you don't want to reference it by name, then the only other ways are by a point to itself ("this"), its ID, or by its index in a collection of elements (however this collection is obtained).

It really depends on the context of how you are creating the listboxes to how you should best refer to them, I'd say. Most people would use "this" in an onchange event... Something like this:

Code:
<select name="wibble" onchange="someFunc(this);">

If that's out of the question, then personally, I think you should stick with the name - it doesn't matter that you create these on the fly - you can still name them without any problems.

Perhaps if you gave us the code you are using to create the listbox, we can better understand how to help you out on this one.

Having the code that you wish to call when the select box changes could also be handy.

Hope this helps,
Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top