Click to See Complete Forum and Search --> : submit form without submit button?


sanjuT
09-17-2003, 09:00 AM
this may be a stupid question, but is there a way to submit a form without aving a submit button visible on the page?

i have a function that submits a form by pressing ENTER, cause in Netscape 4.76 the enter button doesn't work by default:


<!--

function lemmein(keypressed) {
var key;

if (document.all) {
key=window.event.keyCode;
} else {
key=keypressed.which;
}

if (key==13) {
document.form1.submit();
}
}

// -->


and then:

<!--
document.form1.Password.onkeypress=lemmein;
document.form1.user.onkeypress=lemmein;

// -->


Can i use this, or something similar, without having a submit button present?

THANKS!!

pyro
09-17-2003, 09:03 AM
You can submit a form without a submit button, but it relies on javascript, which is a bad thing. How will you keep your pages working for those without javascript enabled?

Anyway, to submit the first form on your page, you can use something like this:

<a href="#" onclick="document.forms[0].submit(); return false;">submit</a>

Khalid Ali
09-17-2003, 09:03 AM
How about voice recognition functionality????(joking)

I guess you can, the only thing that you need to do is to call this line of code

document.formName.submit()

and you can put it in any function to submit the form, it could be a onkypress or onkeyup or any other event

sanjuT
09-17-2003, 09:14 AM
stupid me, the submit thing works if i just take out the submit button. i already had te code that would work (the code i posted).

thanks!

Khalid Ali
09-17-2003, 09:32 AM
you are welcome????

sanjuT
09-17-2003, 09:41 AM
hahaha.

yeah, thanks, u got me pointed in the direction i needed to go.