/    Sign up×
Community /Pin to ProfileBookmark

Difference between <a href> and document.form.submit()

Hi All,

I am using Spring and Velocity.My requirement is, there is a hyperlink, when the user clicks the hyperlink it should call my spring action class and show the data for that Id.

when i used < a href=”<pass the URL here>”> it works fine. Instead of that if i call javascript function and saying,

[code=html]document.forms[0].action=”my actoin path”;
document.form[0].submit();
[/code]

if i give like this , it goes to the action and it submits the form,so i am unable to view my edit page. because once i submit it goes to the SUCCESS page.

i want to know why it happen like this, what difference it really makes when you use < a href> and document.forms[0].submit()??

Pls share with me.

Regards
Kishan.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@scragarOct 21.2007 — if it submits your form to the same page and the link changes the page your going to notice a problem since your loading 2 links in 1 frame/window. use multiple windows/frames to diferentiate or submit the info first, then when submiting is finished follow the link(using ajax or an iframe)
Copy linkTweet thisAlerts:
@kishansauthorOct 21.2007 — HI,

Thanks for your reply. I am not using both <a href> and document.forms[0].submit(). i am using either of these one.
×

Success!

Help @kishans spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...