Jump to content

Get all IDs associated with all textareas


djones

Recommended Posts

I'm using an Edit in place script to edi the contents of textareas on my page. The problem is I don't know the IDs because they are all dynamic. I have assigned a unique id to each one as they are printed on the page, but I need help getting the ID names for each textarea. This is what I started:

var x = document.getElementsByTagName('textarea');

for (var i=0;i<x.length;i++) {

EditInPlace.makeEditable({ id: x[i], type: 'textarea' });

}
check this script out. you can modify it to do what you're after:
[code]
var x = document.getElementsByTagName('textarea');
var count = 0;
var list  = 0;
for (i = 0; i < x.length; i++) {
  myID = x[i].id;
  if (myID != '') {
    count++;
    list += myID + "\n";
  }
}

if (count > 0) alert(list);
else alert('none');
[/code]

this script, when run after the page has loaded, will check all textareas for ids. it will then show the list of all ids that have been pulled from the textareas on the page. if none of them have ids assigned, it will alert "none" to the screen.

hope this helps

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.