Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble with javascript:document.textlink.submit()

Status
Not open for further replies.

milo3169

Programmer
May 2, 2007
42
Hi,

I am working on this project where a sales person can send a Payment Request to a customer where they can pay on-line. So I wrote a PHP script to do that. It would build a dynamic form and send it in a HTML format to the customer. They click on the button and boom; it goes to their shopping cart. Well, some customers experience problems, because they can't view HTML in their email browser, so I wrote a text line with a link that they can choose if they can't see the HTML.
Code:
<a href=\"javascript:document.textlink.submit()\">Click Here</a>

The problem I am having is that when the email is sent the text link is there, but when I click on the link it doesn't submit the form. It just opens a new window and in the url address bar it displays the HREF. When I bypass the mail function and just have the text link display on the browser page, the link works fine. Will someone be able to tell me why the email link is not working?

Thanks in advance.
 
Since you are submitting, (making a page load), you can just do this
Code:
<a href=\"javascript:void(0)\" onclick=\"document.textlink.submit()\">Click Here</a>

The better idea is probably to make a submit button instead of using an anchor, as what I posted isn't considered the greatest practice.

[monkey][snake] <.
 
I tried that, but it looks like it submits to the cart, but then goes back to javascript:void(0) in the URL addres bar. I can't seem to figure this out.
 
My bad, do this
Code:
<a href=\"#\" onclick=\"document.textlink.submit()\">Click Here</a>

I had forgotten that you can't submit with a javascript:void

[monkey][snake] <.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top