javascript blues

They have: 601 posts

Joined: Nov 2001

Hi folks

When it comes to Javascript, I'll be the first to admit that I have absolutely no idea! :-\

Here's what I'm trying to do. I wonder if anyone can help me ...

I've got 5 thumbnails, when the user clicks on the thumbnail, the relevent image loads up as a bigger picture. This isn't a problem. I'm simply using something like:

<img src="/images/ecards/06b.jpg" name="card" width="496" height="234" border="0">

<a href="#" OnClick="card.src='/images/ecards/02b.jpg';">
'
Which instructs the browser to change the "card" image to the one defined when someone clicks on the thumbnail.

Now, however, I need to know which image the user clicked on when the page gets submitted by a form. I think the way I want to do this, is when the user chooses a thumbnail, it writes the to the body of the page the filename chosen, but maybe write it to tags, so I can carry this across with me to the next page.

If anyone knows how to do this, or know of a better way -- please let me know!

Thanks!

- wil

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Off the top of my head, to save it in ,

<a href="#" OnClick="card.src='/images/ecards/02b.jpg'; document.forms.YOUR_FORM.chosen_image.value='/images/ecards/02b.jpg'">

[...]

<form name="YOUR_FORM" action... yada yada>
<input type="hidden" name="chosen_image" value="none">
[...]
</form>
'
This way, thumbnail is enlarged and info is saved in chosen_image.

Note: chosen_image value by default should be something like "none" or "0" so that you can detect if nothing was selected. Or you could leave it blank and check for a returned string length of 0. Although, I'm not sure the latter is reliable... Wink

They have: 601 posts

Joined: Nov 2001

Excellent! Thank you very much for your quick and correct response! Smiling

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

My pleasure. Smiling

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.