Community Forums 

Main Content

Re:HTML form using link instead of button?

    Apr 18 2012 18:08:50

    #1

    anon

    Join date : 2008-09-18      Posts : 488

    It probably doesn't like the this.form. Try this instead:
    <a href="javascript:void(0);" onclick="javascript: document.forms[0].submit();">Buy now</a>

    (edit: below added for completeness)
    or

    <a href="javascript:void(0);" onclick="javascript: document.getElementById('formid').submit();">Buy now</a>

    where formid is the id of the form.

    or

    <a href="javascript:void(0);" onclick="javascript: document.forms['formname'].submit();">Buy now</a>

    where formname is the name of the form.

    In any case, make sure you don't have anything on the page with the name or id of "submit" or it won't work.