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' });

}
Link to comment
Share on other sites

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.