[Javascript] submitting a form using anchor tags

ryan tornberg rtornberg at yahoo.com
Tue May 8 13:04:56 CDT 2001


I have multiple buttons on a form, so I declare them
in HTML as type=button and name them as the form
action.  I then send the button name and form name to
a js function to submit the form.

in HTML

<input type=button name=myURL
onClick=submitMe(this.name, this.form)>

in javascript

function submitMe(action, form)
{
  form.action=action;
  form.submit();
}

This works fine when it's attached to a button.  The
action gets sent as a string and the form gets sent as
an object.  The problem is that when I try to use this
exact same idea in an anchor tag, the form is
undefined.  Do you know how I can get around this?

The following will get to the function, but the form
is undefined.
<a
href="javascript:onClick=addVoucher(Default.ASP?WCI=VoucherDisplay&WCE=Add,
this.form)">Vouchers</a>

The following won't even get to the function because
of a syntax error.  I'm trying to hard code the form
by using the document object.
<a
href="javascript:onClick=addVoucher(Default.ASP?WCI=VoucherDisplay&WCE=Add,
document.frmDisplay)">Vouchers</a>

Any ideas?


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/




More information about the Javascript mailing list