July 30th, 2003, 05:07 AM
I submit my problem as I think it is possible to resolve but I don't find the way to the answer !!
I have an ASP file in which I declare some images :
<IMG NAME="zoom" VALUE="" onClick=changeImage(document.images.name);>
<IMG NAME="pan" VALUE="" onClick=changeImage(document.images.name);>
'document.images.value' stays 'undefined' (even though I put some non-empty string in VALUE="")
So, how could I retrieve the value of images !!!
Secondly : Once the value of the selected image has been changed, I'd like to be able in the asp file to retrieve the value of the images too. Applying :
str = document.images[i].value
====> doesn't work
July 30th, 2003, 09:04 AM
The first thing you need to understand is the difference between Client Side script and Server Side script.
Client Side script is executed/interpreted by *YOUR* browser.
Server Side script is executed/interpreted by the *SERVER*.
Now, assuming that the *SERVER* is in HongKong and that, you the client, is on an airplane overseas with your laptop.
In order for something to happen on the *SERVER* the user must click or do something, in other words some sort of event must be triggered so that your browser makes a request to the *SERVER* in HongKong.
Now, let's get back to your problem...
My first question is:
You are using the <img> tag, but I don't see the src attribute. Shouldn't you have something like:
<img src="images/myimage.gif" width="15" height="15">
NOTE: I've assumed that you had an image called myimage.gif and that it was stored inside a folder called images.
Another thing, I've never used the onclick attribute of the <img> tag, why? because....I've always embedded my <img> tag between an <a href="">...</a> tag when I wanted an image to be clickable.
Fill in the ... with what you have.
Make sure your <img's> are nested between a <form> and a </form> tag
Notice that I haven't passed anything(no parameters) inside the changeImage() function but you could always try something different such as:
That should work...so I think ;-)
Now for the ASP part, you realize that you'll need some sort of "event" happening so that you can retrieve what ever you want to retrieve right?
What you can do(and that is only a suggestion) is to add code inside the changeImage() function so that it looks like this:
//Do whatever needs to be done
//Then right whatever inside a <hidden> field
document.frmMain.hidField.value = xxxxxxxxx;
NOTE: I've assumed that your <form>...</form> name would be called frmMain and that you have a <hidden> field inside that <form>...</form> called hidField.
The xxxxxxxxx part is whatever you need to be put.
Now, ideally, the user should submit your <form>...</form>
Only then will you be able to do something like:
strWhatever = Trim(Request.Form("hidField"))
'FOR DEBUGG ONLY
'Response.Write "-->" & strWhatever & "<--"
Hope this helps!
PS: I realize that I may NOT have answered your question directly but I still hope it did help you out ;-)