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

how do i use variables inside a statement that calls a function?

Status
Not open for further replies.

ripple

Programmer
Jul 17, 2001
6
US
hi, i havent been able to search for this quesiton effectively so i'll ask it here.

how can i use variables inside statements that are calling a function?

for example, say i want to loop through the numbers 1 to 10, and apply the number to the following line where the ## symbols are:

window.document.form.text##.value = "help"

is there a way to do that? i am working around it using a whole bunch of if statements for now.
 
This should do it, but the names will be text1, text2, etc. instead of text01, text02, etc.
Code:
for ( var i=1; i <= 10; i++ ) {
  eval(&quot;window.document.form.text&quot; + i + &quot;.value&quot;) = &quot;help&quot;;
}
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
hie
yeah, & here is another way: (jaredn's advice, works with simple variables, didnt checked with forms & stuff)
window[&quot;row&quot;+ii+&quot;col&quot;+jj]=blahblah regards, vic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top