![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jun 2005
Posts: 29
Rep Power: 0
![]() |
Make Image Clickable
Hi all,
How do you make an image clickable, like a button. I need to make the image function like a button as in say, i have a button with alphabet 'a' and when i click on it, the 'a' comes out in a textbox on the same page. Do i use <img src="a.gif"> or the <input type="image" src="a.gif"> ..? What are the codes for the onClick event? Thanks.. |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
|
[html]
<script> function putToBox(incvar){ document.getElementById("despout").value = incvar; } </script> <body> <a href="#" onclick="putToBox('a')"><img src="a.gif"></a><br> <input type="text" id="despout"> </body>[/html] |
|
|
|
|
|
#3 |
|
Programming Guru
![]() ![]() |
he's how i'd do it.
<body> <input type="image" src="somepic.gif" alt="Go to Google" name="go_to_google" onclick="javascript:window.location='http://www.google.com'"> </body> one line of code :-) note that you can also use this method to submit forms to your server.
__________________
Profanity is the one language that all programmers understand. Check out my Blog <---updated Nov 30 2007! |
|
|
|
|
|
#4 | |
|
Programming Guru
![]() |
Quote:
__________________
|
|
|
|
|
|
|
#5 | |
|
Hobbyist Programmer
|
@tempest: Wow, aparently you diden't notice Pizentios did the same thing. Now ur just turning into an a$$.
Quote:
|
|
|
|
|
|
|
#6 | |
|
Professional Programmer
|
Quote:
Refrain from using IM-speak and profanity towards elder members, or stop posting all together if you can't.
__________________
% rc4 hexkey < input > output
#define S ,t=s[i],s[i]=s[j],s[j]=t /* rc4 hexkey <file */
unsigned char k[256],s[256],i,j,t;main(c,v,e)char**v;{++v;while(++i)s[
i]=i;for(c=0;*(*v)++;k[c++]=e)sscanf((*v)++-1,"%2x",&e);while(j+=s[i]
+k[i%c]S,++i);for(j=0;c=~getchar();putchar(~c^s[t+=s[i]]))j+=s[++i]S;} |
|
|
|
|
|
|
#7 |
|
Programming Guru
![]() ![]() |
you can actually use the onclick attribute in a img tag as well, but your users won't get the little hand that you get when you put your mouse over a link.
Example: <img src="somepic.gif" alt="Go to Google" onclick="javascript:window.location='http://www.google.ca'">
__________________
Profanity is the one language that all programmers understand. Check out my Blog <---updated Nov 30 2007! |
|
|
|
|
|
#8 |
|
Hobbyist Programmer
|
It also wont be recoganised as a link. If you use the tab key to navage the site (as i sometimes do) you will never be able to get to that link. It will get the job done but only as a last resort.
|
|
|
|
|
|
#9 |
|
Programming Guru
![]() |
If you want to keep up with xHTML standards and don't want to make a form just for the clicking of the link to get by validation you could also do this, giving you the "link cursor" effect.
[php] <img src = "img.gif" onclick = "javascript: window.location='http://www.google.com';" onmouseover = "javascript: this.style.cursor = 'pointer';" onmouseout = "javascript: this.style.cursor = 'default';"> [/php]
__________________
|
|
|
|
|
|
#10 | |
|
Hobbyist Programmer
|
Quote:
|
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|