Connecting Tech Pros Worldwide Forums | Help | Site Map

syntax question to catch dynamically generated divs in a page

Newbie
 
Join Date: Nov 2006
Posts: 11
#1: Nov 11 '06
i've got a -maybe dumb- question since i've never had a single js lesson :)

i want to catch some divs in a page, at first i got all the names of them from a db, but now they are dynamicly generated.
so.. i couldnt use php anymore.. so.. this is what i came up with:


Expand|Select|Wrap|Line Numbers
  1.  if (obj.name.match('resize'))
  2.     {
  3.     instance = str.replace(/resize/,"");
  4.  
  5.     elements.q+instance+.resizeTo(dd.obj.x-elements.q+instance+.x+12, ((obj.y+12)-dd.elements.q+instance+.y));
  6.         elements.opt+instance+.moveTo(dd.obj.x-24, dd.obj.y);
  7.         elements.movemove+instance+.moveTo(dd.obj.x-12, dd.obj.y);
  8.         }
well, this doesnt work.
example:
object name is "resize1"
i strip resize
and i want to get:
elements.movemove1.moveTo(dd.obj.x-12, dd.obj.y);

you know what i mean :)

acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: May 28 '08

re: syntax question to catch dynamically generated divs in a page


Assuming these are the IDs, use document.getElementById:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("q"+instance)...
Reply