hi guys
i want to to display image on buttons in my web so how can i do this in html
image on button
Moderator: General Moderators
-
cpetercarter
- Forum Contributor
- Posts: 474
- Joined: Sat Jul 25, 2009 2:00 am
-
hemakumarrr
- Forum Newbie
- Posts: 7
- Joined: Mon Nov 09, 2009 12:42 am
Re: image on button
Hi,
We can use image as both button and submit.
Image as Button :
<img src="SomePath" onclick="SomeFunction()" />
Image as Submit :
<input type="image" src="SomePath" />
Hope you know whats the difference between Submit and Button.
<input type="button" onclick="SomeFunction()" />
<input type="submit" />
We can use image as both button and submit.
Image as Button :
<img src="SomePath" onclick="SomeFunction()" />
Image as Submit :
<input type="image" src="SomePath" />
Hope you know whats the difference between Submit and Button.
<input type="button" onclick="SomeFunction()" />
<input type="submit" />
Re: image on button
how can i use java script on image like i want to call a php page by clicking on image how i do this
waiting for ur replies
waiting for ur replies
Re: image on button
depends on what you want to do with your PHP page as to whether you need javascript or notmyasirm wrote:how can i use java script on image like i want to call a php page by clicking on image how i do this
you could just set an "onClick='doFunction(varName)'" for your image tag. and tell the script to submit a form to a php page.
or just redirect to a php page based on php input "<a href='myPHPPage.php?myVar></a>"
there is a few other ways too... but it depends what your needs are.
-
hemakumarrr
- Forum Newbie
- Posts: 7
- Joined: Mon Nov 09, 2009 12:42 am
Re: image on button
<script language="javascript">
function callphp()
{
document.f2.submit();
}
</script>
<form name="f2" action="sample.php">
<input type="image" src="sample.img" />
<img src="sample.img" onclick="callphp()" />
</form>
(or)
<script language="javascript">
function callphpfile()
{
window.location="sample.php";
}
</script>
function callphp()
{
document.f2.submit();
}
</script>
<form name="f2" action="sample.php">
<input type="image" src="sample.img" />
<img src="sample.img" onclick="callphp()" />
</form>
(or)
<script language="javascript">
function callphpfile()
{
window.location="sample.php";
}
</script>
Re: image on button
Just use the <button> tag. Much simpler than mucking around with Javascript.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.