Forum Moderators: open

Message Too Old, No Replies

Graphic Form Buttons -'dinging'

         

bruhaha

6:59 pm on Oct 16, 2002 (gmt 0)

10+ Year Member



We have several forms on our web site. Recently we replaced the standard gray HTML form buttons with graphic buttons.

To make the 'submit' button work when the "Enter" key is pressed (as it does with the standard form buttons), we added the javascript function below. It is called with onKeyPress in the body tag of the page with the form.


function checkEnter(event)
{
var code = 0;
if (NS4)
code = event.which;
else
code = event.keyCode;

if (code==13) {document.forms[0].submit();
}

The code works fine for submitting the form. The only problem is that, whenever it is called (that is whenever you try to submit the form by pressing "Enter" when the focus is not already on the button), many of our machines let out the noisy "ding" that usually accompanies a warning message.

Any ideas on how we can get rid of the noise?

TallTroll

10:38 pm on Oct 17, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmmm, can this be controlled from the windows control panel? Isn't there a screen buried in there that allows you to allocate .wav file to certain events?

I'm a bit fuzzy on it myself, but someone must know where it is...

RossWal

11:21 pm on Oct 17, 2002 (gmt 0)

10+ Year Member



Here's a silly thought. Can you hide a submit button by making it 1px-by-1px and blending it into the background (or maybe positioning a layer on top of it), then use the onlick for that to do whatever it is you want? I'm assuming you can get a button down to 1x1 since you can vary height & width, but I've sure never tried to go that small. Heck, maybe 0x0 will work?

hth

bruhaha

7:07 pm on Oct 18, 2002 (gmt 0)

10+ Year Member



Can you hide a submit button by making it 1px-by-1px

Well, that's very close to the solution that finally hit me early yesterday afternoon. I added the following to the bottom of each form:

<input type="submit" value="Submit" class="hidden">

Then, in the stylesheet I wrote:


.hidden {
height:0px; width:0px;
}

It struck me as too simple, but it works beautifully --people can still click on the visible graphic button (or tab to it), or simply hit "Enter". (I have now removed the javascript function from these pages. Still trying to find a glitch, but nothing so far. . . )

bruhaha

7:09 pm on Oct 18, 2002 (gmt 0)

10+ Year Member



Hmmm, can this be controlled from the windows control panel?

I think you're right. But I couldn't figure out how that would help me with any visitors to our web page who were annoyed by the ding.