Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variables and DOM

Status
Not open for further replies.

zwarte

Programmer
Joined
Jul 5, 2002
Messages
9
Location
BR
Hello Again,

Is it possible to pass a variable to an object model reference? In example:

var j = new Date();
var s = j.getDate();

For instance today is July 5th.
The variable s will return the number 5.

I want to be able to take that number and plug it into something like

document.all."var if possible".cols

Is this possible?

-Jay
 
Do you want the result to be document.all.5.cols only if the number 5 exists? I don't understand that. There will always be a number if it is a day on the calendar. If that's what you want, try document.all.s.cols or else document.all.s.value.cols I can't remember how that works right now and I have to go right away, so good luck!

Rick If I have helped you just click the first link below to let me know :-)
 
zwarte,

perhaps you're asking this?
Code:
var j = new Date(); 
var s = j.getDate();

if (eval("document.all.o" + s))
  eval("document.all.o" + s + ".cols...rest of your code here...)

this will execute your code if the element/id exists...

also, remember that ids and variable names cannot start with numbers: I've called your ids above "o" + s for this reason.

======================================

if (!succeed) try++
-jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top