# Determining loop row number via JavaScript for computed texts

Community Member Qubie ✭

# Determining loop row number via JavaScript for computed texts

Hi Qualtrics community - I have a complicated text fill situation which I THINK would be easier to deal with if I could add a JavaScript OnReady computation for the current row of a loop, but I don't know how to determine what row I'm on via JavaScript. Below is the scenario:

Q1
"At what age did you start smoking regularly?"
___ age

Q2
"At what age did you stop smoking?"
___ age

[Begin Loop]
Row 1: represents X to 17
Row 2: 18 to 24
Row 3: 25 to 29
Row 4: 30 to 34
etc. up to 70+ category

CIGLIFE
"About how many of the years from age [X] to age [Y] did you smoke cigarettes?"
On loop 1, X = lower bound of the loop OR Q1 if appropriate
Y = upper bound of loop OR Q2 if appropriate

Example: if on ROW 2 and Q1 = 15 and Q2 = 23 then the text would read:
"About how many of the years from age 18 to 23 did you smoke cigarettes?"

I feel like if I could determine what row of the loop I'm currently on during the OnReady then I could update the text displayed on the screen dynamically.

Tagged:

• Raleigh, NC Wizard ✭✭✭✭✭

You can use:

```parseInt("\${lm://CurrentLoopNumber}");
```

• Community Member Qubie ✭

I think this might work - going to test it out and will get back to the thread!

• Raleigh, NCCommunity Member Wizard ✭✭✭✭✭

@Pete_L said:
I think this might work - going to test it out and will get back to the thread!

I had a typo that I corrected above. There is no 't' in parse.

• Community Member Qubie ✭

Works as expected! Thanks TomG! I actually ended up using this to solve other loop related issues.