Ziga
Programmer
- Jun 9, 2010
- 2
Hi, I'm sort of new to javascript and I'm having a problem
this is my code
for(i=1;i<=68;i++){
content+="<p onclick='myf(i)'>Some text</p>";
}
What I'm trying to do is that when you click on this text it would send the index of it to function 'myf'. But in the code as I have it above it would send 68 for all paragraphs. How could I put the value of i in the parameter instead of 'i'? Like '1' and '2' and so on.
And this isn't the actual code, it's just simplified. I have an array and it would send array.
Thanks for any help.
this is my code
for(i=1;i<=68;i++){
content+="<p onclick='myf(i)'>Some text</p>";
}
What I'm trying to do is that when you click on this text it would send the index of it to function 'myf'. But in the code as I have it above it would send 68 for all paragraphs. How could I put the value of i in the parameter instead of 'i'? Like '1' and '2' and so on.
And this isn't the actual code, it's just simplified. I have an array and it would send array.
Thanks for any help.