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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using a function parameter as a reference to an object

Status
Not open for further replies.

martynj

Programmer
Oct 19, 2001
11
GB
I have a vbscript function which accepts a parameter which is the name of an object.

In javascript I can pass the parameter as a text string and then run the following code..

function first(dataSetName){
var dataRS = document.all[dataSetName].recordset;
dataRS.moveFirst();
;
}

I dont seem to be able to do this. I want to pass in a value to dataSetName and then use this as the reference to the element on the page. It could be a textbox or in the case above a dataisland.

REgards

Martyn
 
Try

Code:
var dataRS = eval("document.all."+dataSetName+".recordset");
________
George, M
 
Or
eval("var dataRS=document.all."+dataSetName+".recordset");
if the first wont work...
eval function execute the string u put as parameter
and in the first example it must return the execution value to the variable, but the last one is shure... ________
George, M
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top