Forum Moderators: open

Message Too Old, No Replies

Using text link as submit button?

         

doctormelodious

2:57 am on Jun 18, 2004 (gmt 0)

10+ Year Member



Greetings,

I know I can use an image as a submit button on a form. Is it possible to use a text link?

I tried this in a form that works fine when it uses a normal submit button:

<a href="" onClick="this.form.submit();" style="text-decoration:none">Upload</a>

but it didn't work. (The empty URL was to make it clickable.)

Thanks!
Perry

DrDoc

3:04 am on Jun 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you need to add
return false
to the onclick event to cancel the normal link behavior.

doctormelodious

3:40 am on Jun 18, 2004 (gmt 0)

10+ Year Member



Hi DrDoc,

Thanks for the quick reply! I tried this:

<font face=arial,helvetica size=1><b><a href="" onClick="this.form.submit();return false;" style="text-decoration:none">Upload</a></b></font>

and this:

<font face=arial,helvetica size=1><b><a href="" onClick="return false;this.form.submit();" style="text-decoration:none">Upload</a></b></font>

but the form still failed to submit. Is there another place I should try the "return false"?

Thank again,
Perry

DrDoc

3:49 am on Jun 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oh, and, I just noticed one more thing... You can't refer to the form with
this.form
since the hyperlink is not part of the form. You can, however, do something like
document.forms[0].submit()

doctormelodious

4:29 am on Jun 18, 2004 (gmt 0)

10+ Year Member



DrDoc,

You rock! That did the trick.

Thanks!
Perry