dcsimg
www.webdeveloper.com
Results 1 to 7 of 7

Thread: asign mutiple function to a link

  1. #1
    Join Date
    Nov 2010
    Posts
    8

    Question asign mutiple function to a link

    i have 3 links... (eg. stomach, brain and heart). and also 3 images (stomach.gif, brin.gif and hear.gif) when i click stomach i want to display the image of stomach and hide the rest. ALSO there are another 2 links (view cross-section, and view inside) and images associated with this
    if stomach is selected, clicking the 'view corss-section' should display corss-section image of the stomach (together with the stomach image).....if brain is selected, clicking 'view corss-section' should display corss-section image of the brain....and so on...Hope you got the question....Can any pls tel how to write some javascrip code to this...i am somewhat new programming...thanks in advance

  2. #2
    Join Date
    Nov 2010
    Posts
    86
    Quote Originally Posted by samusa22 View Post
    i have 3 links... (eg. stomach, brain and heart). and also 3 images (stomach.gif, brin.gif and hear.gif) when i click stomach i want to display the image of stomach and hide the rest. ALSO there are another 2 links (view cross-section, and view inside) and images associated with this
    if stomach is selected, clicking the 'view corss-section' should display corss-section image of the stomach (together with the stomach image).....if brain is selected, clicking 'view corss-section' should display corss-section image of the brain....and so on...Hope you got the question....Can any pls tel how to write some javascrip code to this...i am somewhat new programming...thanks in advance
    Hi. The short answer is you can detect which images are currently visible and choose which ones to show or hide accordingly.

    There are many ways to do this.

    Here is a quick and simple example:

    http://webinterfacetricks.com/images_test/

    I have put comments in the source code to explain how it's done. Please say if you have any questions or if I have misunderstood your question.
    Last edited by interfacetricks; 11-16-2010 at 12:50 AM.

  3. #3
    Join Date
    Nov 2010
    Posts
    8
    Thank you very much...Thats what i wanted..In the same Can i have two accompanying button for 1 image. I mean one to 'view inside' (the stomach) and other one to 'view cross-section'...Loads of thanks once again

  4. #4
    Join Date
    Nov 2010
    Posts
    86
    Quote Originally Posted by samusa22 View Post
    Thank you very much...Thats what i wanted..In the same Can i have two accompanying button for 1 image. I mean one to 'view inside' (the stomach) and other one to 'view cross-section'...Loads of thanks once again
    Yes, you can use the "arguments" object that javscript provides. It represents all arguments passed into a function so you don't have to declare each one specifically in the function definition. You can therefore pass in as many element IDs as you want, and then display only those.

    I have modified the example to do this.

    http://webinterfacetricks.com/images_test/

    Again you can see the source code for more detail.

  5. #5
    Join Date
    Nov 2010
    Posts
    8
    Once again thanks a lot....One more thing..Referring to the FIRST reply, how can i make the ' Show Accompanying image' button to change its text...Once some1 click this button i want to change its text to 'Hide Accompanying image' AND when click it should hide the accompanied image changing AND change text back to 'Show Accompanying image'

  6. #6
    Join Date
    Nov 2010
    Posts
    86
    Quote Originally Posted by samusa22 View Post
    Once again thanks a lot....One more thing..Referring to the FIRST reply, how can i make the ' Show Accompanying image' button to change its text...Once some1 click this button i want to change its text to 'Hide Accompanying image' AND when click it should hide the accompanied image changing AND change text back to 'Show Accompanying image'
    You can change the button's text by passing a reference to the button, in to the function that runs when you click it. You can pass an element's reference to one of its event functions using the "this" keyword (see example at address below).

    Then in the button's onclick function you can manipulate its contents and behaviour, for example

    button.firstChild.nodeValue = "new text";
    button.onclick= function(){do_something_different();}

    I've modified the previous example so that if you click the "show accompanying images" button it changes its text to "hide accompaying images" and changes it onclick function as well.

    See the example here.

    http://webinterfacetricks.com/images_test/

    Please let me know if you have any questions about how it works.

  7. #7
    Join Date
    Nov 2010
    Posts
    8

    Question another buttion

    Loads of thanks again...i need another button... i tried... please help
    with what u gave i have made a sample page here...http://www.scicomonline.com/dnmic/sample.html#
    i want if the flower is selected clicking for lesson notes to load flower.html (or a url) if brain is selected clicking lesson notes take u to brain.html

    thank you

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles