|Ho do you emulate submit button click on an image|
just using a href?
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:
<input type="hidden" name="hello" value="goodbye">
<input type="image" src="pathtoimage" name="do" value="submit">
I'm "missing" the alt tag displaying, plus it's so much easier to just do
<a href="url"><img src="pathtoimage"></a>
I think what you already have is correct, if you are wanting an image to submit a form then using:
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"... |
<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?!
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!
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.
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!
Really? I've had lots of machines, they all "click"....
but that "title" thing is helpful, thanks!
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.
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 ) 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.
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?
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..