Hi all my name is codingcon and i just joined daniweb :), i am new to the the javascript language and only have the basics down. Ihave this idea that i want to make and i just dont know how to do this one thing. basically i wanna know how to basically make an if statement for when a user clicks a button(In this case a picture) print a character on the screen. I know how to print a character on the screen i jsut dont know how to make the if statment sense the clicking of a picture. Thanks.

6 Years
Discussion Span
Last Post by antonioazevedo

Normally you attach something to an event instead of an if statement.
For example:

<img src="image.jpg" onclick="imageClick()" />

<script type="text/javascript">
    function imageClick() {
        // do something

or you could directly do onclick=" *do something *" but I find it better this way.


ahh i see thank you. But the reason i wanted an if statement because i wanted to basically do if the person taps this picture then another picture in a certain pattern then print a charater.


I'm not sure if I understand.
You want to be able to define a path, like if users click picture 1 then click picture 2 do something?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.