[Javascript] submitting a form using anchor tags
staeger
staeger at arch.ethz.ch
Tue May 8 13:32:54 CDT 2001
ryan tornberg wrote:
>
> 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?
try to change your hrefTag:
<a href="#" onClick="addVoucher('newUrl',document.frmDisplay); return
false;">
Vouchers
</a>
instead of document.frmDisplay you can also use
document.forms['frmDisplay']
greets ben./
-------------- next part --------------
A non-text attachment was scrubbed...
Name: staeger.vcf
Type: text/x-vcard
Size: 461 bytes
Desc: Card for staeger
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20010508/8b740263/attachment.vcf>
More information about the Javascript
mailing list