Welcome to WebmasterWorld Guest from 107.21.183.163

Forum Moderators: open

Message Too Old, No Replies

Ho do you emulate submit button click on an image

just using a href?

     

Clark

2:49 pm on Aug 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello,

I've got an image meant to look like a submit button. I'd like when the image is clicked to get the same click the browser gives when clicking submit.

While I can emulate this by doing something like:

<form action="whatever">
<input type="hidden" name="hello" value="goodbye">
<input type="image" src="pathtoimage" name="do" value="submit">
</form>

I'm "missing" the alt tag displaying, plus it's so much easier to just do

<a href="url"><img src="pathtoimage"></a>

Is there a javascript to cause a click when pressed? Preferably inline so I can just do an "onclick"=?

penders

4:13 pm on Aug 29, 2006 (gmt 0)

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



I think what you already have is correct, if you are wanting an image to submit a form then using:

<input type="image"....

is the way to go. This is a submit btn. It behaves the same as an <input type="submit"... and you can also add a alt and title attributes to give your users some popup text.

If, however, you want to submit a form that is on the page, but from an image (click) which is not within that form, then you can do...

<form name="myform"...
Form stuff...
</form>

<img src="mybutton.gif" onclick="myform.submit();">

But personally, I would stick to the first example, with type="image" if possible.

----------------

ASIDE: I've found that a submit button with type="image" is not passed to PHP, key/value pairs?! Am I missing something?!

penders

6:12 pm on Aug 29, 2006 (gmt 0)

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



Anyone reading can ignore that last ASIDE note above, as I've found the answer was actually in the question... I was missing the value attribute from the <input> tag, so naturally the key/value pair wasn't generated! Oops!

Clark

6:57 pm on Aug 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I must not have been clear. I can get this to work if I use the "form" trick. (although specifying "alt" text is not getting me the tooltip popup text for some reason).

What I'm trying to do is achieve the same affect as if it was a form, but having it only as an <a href> link.

In other words, it's just an image attached to a link. I still want to hear the "click" sound.

I hope it was clearer.

penders

10:21 pm on Aug 29, 2006 (gmt 0)

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



You'll need to specify a title="Popup text here" attribute in your <input> tag to get a popup message.

But it's the 'click' *sound* you are after?! My machine does not make any sound when I click on a (submit) button, whether it's in a form or not, and my machine is pretty much in its default configuration as far as that sort of thing goes.

Whether a users machine makes a click sound on a standard HTML form submit is very much down to the users individual machine - I think!

Clark

10:46 pm on Aug 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Really? I've had lots of machines, they all "click"....

but that "title" thing is helpful, thanks!

If someone else got some "click javascript", will still be happy for it :)

Rambo Tribble

1:54 am on Aug 30, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The click sound is probably a feature of the browser you are using and its configuration. For instance, on my machine Firefox is generally silent while Konqueror makes all manner of odd grunts, clicks and squeals.

penders

10:24 am on Aug 30, 2006 (gmt 0)

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



Hhhmmm, yeah... just out of interest... I do get a click sound from IE5 on Win98 when clicking on links, but *not* on form submits. (The system sounds on that machine have probably been configured in the past.) In all other cases, I get no click sound at all... Win98 - FF, Opera7, N4(!). WinXP - IE6, FF, Opera8. (And I've got the volume turned way high!)

I did wonder about ASCII code 7 (maybe &#7) which is historically a 'beep' but that doesn't seem to work!

The other possibility maybe to embed a sound (a small .WAV file) into a page with EMBED/BGSOUND and somehow trigger the sound (change the SRC attribute perhaps) via the onclick event of the link. But it seems like a lot of work for something which 'might' work on 'some' machines - and people could find annoying.

HeadBut

5:50 pm on Aug 30, 2006 (gmt 0)

10+ Year Member



Is it possible to catch a mouse click while a script is running, like an AJAX update, then play a sound to indicate the erant click will not be responded to?

Thanks
M

Clark

7:12 pm on Aug 30, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I just tested it and it turns out my brain "remembered" a click sound and I assumed it was in Firefox, but it was a memory from ie. The brain really plays weird tricks on you. Or I'm just getting old..
 

Featured Threads

Hot Threads This Week

Hot Threads This Month