djones Posted August 23, 2006 Share Posted August 23, 2006 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' }); } Quote Link to comment Share on other sites More sharing options...
obsidian Posted August 23, 2006 Share Posted August 23, 2006 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 Quote Link to comment Share on other sites More sharing options...
djones Posted August 23, 2006 Author Share Posted August 23, 2006 Works. Thanks. I wan't sure how to get the ids in the loop for each textareamyID = x[i].id; // crucial partThanks! Quote Link to comment Share on other sites More sharing options...
obsidian Posted August 23, 2006 Share Posted August 23, 2006 keep in mind that [i]typically[/i], you can access the value of nearly any attribute (e.g. name, alt, width, src, etc) by simply referring to that attribute like the ".id" above. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.