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

are macro substitutions possible in javascript??

Status
Not open for further replies.

kakmouth

Programmer
Oct 26, 2001
20
hi.

just wondering if it is possible to do a macro substitution in javascript...

for example if i define a string variable as:

<< var lsText = &quot;document.Form1.txt_PONum&quot; >>

where document.Form1.txt_PONum is a textbox on Form1, would i then be able to substitute that text/variable in a line of code calling for the click() method of that textbox:

<< document.Form1.txt_PONum.click() >>

but substitute like:

<< {lsText}.click() >>

????

any help would be greatly appreciated...

thanks. mike
 

yes...

var lsText = document.Form1.txt_PONum

then you call it as IsText.click()...

no quotes.


- spewn
 
spewn,

thanks for the response...

the problem that i am having is that i need to create the string variable holding the name of the form's object dynamically... for instance,

>> lsText = &quot;document.Form1.But&quot;+lcNum

where lcNum is a charcter parameter (&quot;1&quot; thru &quot;9&quot;) and &quot;But1&quot;, &quot;But2&quot;, etc. are buttons on Form1.

and then call the click() method of that button...

lsText.click()

any thoughts???
 

try...

**
lsText = eval(&quot;document.Form1.But&quot;+lcNum);
**

does that help?


- spewn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top