Red-d
12-30-2004, 07:46 PM
Hi,
I have a very limited experience in javascript and I would like to know if it posible to use a variable to refer a object in my doccument as I would do with php for exemple.
There a sample of the code I want to use
<SCRIPT LANGUAGE=JavaScript>
function swapImage(id) {
id = 'IMG'+id;
switch (intImage) {
case 0:
"id".src = "http://example.com/images/flag_0.jpg"
intImage = 1
return(false);
case 1:
"id".src = "http://example.com/images/flag_1.jpg"
intImage = 2
return(false);
case 2:
"id".src = "http://example.com/images/flag_2.jpg"
intImage = 0
return(false);
}
}
</SCRIPT>
This function receive in parameter the number or the image I want to change the source and change it. I want to change the image with the name of the variable. For example: IMG227.
What im trying to do is to input a flag system to our help desk. Every line start with a image (which is a kind of flag) and when the user click on it, it change the flag color. So evry image has the name of the ID of the help thread of the line.
As it's my first time posting here I hope my question is clear ennough.
Thank you in advance
I have a very limited experience in javascript and I would like to know if it posible to use a variable to refer a object in my doccument as I would do with php for exemple.
There a sample of the code I want to use
<SCRIPT LANGUAGE=JavaScript>
function swapImage(id) {
id = 'IMG'+id;
switch (intImage) {
case 0:
"id".src = "http://example.com/images/flag_0.jpg"
intImage = 1
return(false);
case 1:
"id".src = "http://example.com/images/flag_1.jpg"
intImage = 2
return(false);
case 2:
"id".src = "http://example.com/images/flag_2.jpg"
intImage = 0
return(false);
}
}
</SCRIPT>
This function receive in parameter the number or the image I want to change the source and change it. I want to change the image with the name of the variable. For example: IMG227.
What im trying to do is to input a flag system to our help desk. Every line start with a image (which is a kind of flag) and when the user click on it, it change the flag color. So evry image has the name of the ID of the help thread of the line.
As it's my first time posting here I hope my question is clear ennough.
Thank you in advance