It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Images as buttons

Images as buttons

Postby mel1 on Thu Jun 19, 2008 8:17 am

Can anyone tell me how to use an image instead of a button to display an alert message. I.e. how what do I put in the input type in place of button and what about the value?


function saySomething(message){
alert(message)
}

<form action = "#"
<input type="button" value="Welcome"
onclick="saySomething('Welcome to my page')"/>
</form>

Any help appreciated.
mel1
 
Posts: 6
Joined: Tue Jun 17, 2008 10:32 am

Postby rangana on Thu Jun 19, 2008 8:22 am

The same thing applied, use an inline event handler, in your case onclick.
Code: Select all
<img src="myimage.jpg" onclick="saysSomething('Welcome to my page')" alt="this is my image"/>


Hope it helps.
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines


Who is online

Users browsing this forum: No registered users and 9 guests