i understand the problem but i cant achieve what i want.
all the code i wrote before are inside a for loop like this:
for (int i=0;i<n;++i){
with (document) {
writeln("<TD><A HREF='javascript
:myOwnFunction(str);'><IMG
SRC='images/picture.jpg' BORDER='0'></A></TD></TR>");
}
}
so i want to create a table with n rows, but each one calling myOwnFunction
with the value of "i" as the parameter, that is, row 1 link will call
myOwnFunction('1'), row 2 link will call myOwnFunction("2"), etc.
and that is what i cant get it working.
plz help
"Lasse Reichstein Nielsen" <lr*@hotpop.com> escribió en el mensaje
news:pt**********@hotpop.com...
"yukatan" <a@a.com> writes:
I have the following Javascript piece of code in a .js file (it's a
function that generates a new html page with a button to call a function).
var str = "hello";
This variable is declared inside a function. That means that it can only
be seen inside that function's body. The Javascript that you write will
not be inside this body, so "str" will not be defined for it.
Solution: move 'var str="hello";' outside the function. That will
make it a global variable.
// some code
with (document) {
// some writes
writeln("<TD><A HREF='javascript:myOwnFunction(str);'><IMG
SRC='images/picture.jpg' BORDER='0'></A></TD></TR>");
Don't use "javascript:".
<URL:http://jibbering.com/faq/#FAQ4_24>
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors:
<URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html> 'Faith without judgement merely degrades the spirit divine.'