[UPHPU] javascript syntax

Aaron Luman aaron.luman at gmail.com
Mon May 2 10:51:22 MDT 2011


you could do:

for(var j=0; j<10; j++) {
	var the_row = 'tr_' + j; // create the id field value
     var rowDisplay = eval("document.getElementById(the_row).style.display";
     alert ("display is " + rowDisplay);
}

I tried it on a webpage that uses mooTools and one that uses jQuery, it worked on both.

javascript:(function(){target='*target_id*';alert(document.getElementById(target).innerHTML);})();

I'm pretty sure it will work in javascript with no added libraries.

Aaron

On May 2, 2011, at 9:41 AM, Merrill Oveson wrote:

> phpers:
> 
> struggling with this....
> 
> 
> This works:
> 
> var rowDisplay = document.getElementById('tr_1').style.display;
> 
> 
> How do I put the tr_ into a for loop?
> 
> i.e.
> 
> for(var j=0; j<10; j++) {
>      var rowDisplay = eval("document.getElementById('tr_'" + j +
> ").style.display";
>      alert ("display is " + rowDisplay);
> }
> 
> 
> or
> var rowDisplay = document.getElementById['tr_' + j].style.display;
> 
> ?
> 
> I'd prefer not to use the eval if I don't have to.
> 
> Thanks
> 
> Merrill
> 
> _______________________________________________
> 
> UPHPU mailing list
> UPHPU at uphpu.org
> http://uphpu.org/mailman/listinfo/uphpu
> IRC: #uphpu on irc.freenode.net



More information about the UPHPU mailing list