Forum Moderators: open

Message Too Old, No Replies

Changing a variable by clicking on an image

         

abledj

5:15 pm on Mar 3, 2010 (gmt 0)

10+ Year Member



I've designed a page that contains a scrolling gallery using JQuery.

The page contains a frame whos content changes by clicking various menu options.

What I want to be able to do is when I click on a menu item (an image with a link changing the content of the frame) I want to change the variable containing the set of images for the gallery as well as changing the content in the frame.

Is this possible? I know I could do it with a button, but I'm not so sure with an image.

abledj

5:16 pm on Mar 3, 2010 (gmt 0)

10+ Year Member



By the way, my javascript knowledge is limited but should be able to muddle along with any advice! ;)

seoul

6:51 pm on Mar 17, 2010 (gmt 0)

10+ Year Member



Assuming your work flow is asfollows:
■ when you click on a menu item (an image with a link changing the content of the frame), the variable containing the set of images for the gallery changes
■ The content of the frame is also changed.

Right now the content of the frame is changed so you've to add the variable changing facility only. To do this edit the link's onclick event on the menu items. I mean you have to insert a simple funciton.

Let currently the link with image is as follows:

<a hreft="example.com"><img src="example.com/my_image.gif" ></a>

You wish to make sure when this link is clicked a variable named "str" will be changed. So change the above link as:

<a hreft="example.com" onclick="func();return true;"><img src="example.com/my_image.gif" ></a>


and insert this javascript after the link for the javascript function:

<script type="text/javascript">
function func()
{
str= "changed valued goes here";
}
</script>