Results 1 to 2 of 2

Thread: onclick image

  1. #1
    bop97 is offline Member
    Join Date
    Nov 2016
    Posts
    1
    Rep Power
    0

    Default onclick image

    So i have to do this exercise where i am asked to when the user clicks on a image, that is not a button, it changes to another image and i also have to limit the amont of times i can click it. I need to limit it to 3 options, and i have no ideia how. Can anyone give me a hand? here goes my code.



    <html>
    <body>
    <h1 style="text-align:center;">Apostas</h1>

    <p style="text-align:center;">
    <img id="n1" src="1.png" onclick="A()">
    <img id="n2" src="2.png" onclick="B()">
    <img id="n3" src="3.png" onclick="C()">
    <img id="n4" src="4.png" onclick="D()">
    <img id="n5" src="5.png" onclick="E()">
    <img id="n6" src="6.png" onclick="F()">

    <script>
    function A()
    {document.getElementById("n1").src="cruz.png";}
    function B()
    {document.getElementById("n2").src="cruz.png";}
    function C()
    {document.getElementById("n3").src="cruz.png";}
    function D()
    {document.getElementById("n4").src="cruz.png";}
    function E()
    {document.getElementById("n5").src="cruz.png";}
    function F()
    {document.getElementById("n6").src="cruz.png";}
    </script>

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,989
    Rep Power
    32

    Default Re: onclick image

    Moved. Java != javascript
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. JSF Manipulate onclick value
    By alafarm in forum JavaServer Faces (JSF)
    Replies: 0
    Last Post: 09-28-2012, 10:17 PM
  2. OnClick Image for Robot arm interface
    By ApheoXAIO in forum New To Java
    Replies: 1
    Last Post: 08-24-2010, 11:33 PM
  3. help with onclick
    By unplugged in forum Java Applets
    Replies: 4
    Last Post: 12-15-2009, 12:24 AM
  4. use of onclick function
    By m4tt in forum New To Java
    Replies: 1
    Last Post: 02-16-2008, 03:03 AM

Posting Permissions

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