468,117 Members | 1,423 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,117 developers. It's quick & easy.

jQuery Submit with show/hide specific div and multiple forms not working as it should

2 2Bits
Hello,

I have a page with multiple users listed, and for each user multiple forms that should be able to be submited individual, with a response div that shows up on successfull submit and then disapear again af 10 sec. when I have a single form it works as it should, although you are only able to submit 1 time, but the big issues comes when I have multiple forms:

Issues:

1 : Even though I use let response_div = $(this).prev(); it always target the top DIV, and not the DIV above.
2 : I am only able to submit 1 time, so if the user needs to correct something, they are not able before they reload the page again.
3 : Field validation is also performed outside the form, i.e. the required is triggered in a different form than the one I submit.

I have placed the code in a fiddle here: https://jsfiddle.net/skolbaek/2j4skwyr/2/

I hope someone can help :-)

/Stig :-)
Mar 9 '21 #1
3 1743
Dormilich
8,651 Expert Mod 8TB
The main issue would be that response_div is also an id and it's used multiple times. I also suspect that let may not be the right keyword for this use-case.
Mar 9 '21 #2
skolbaek
2 2Bits
I had my suspicions that one of the issues where the naming of the DIV, but how can I make that Dynamic in the jQuery? .. I can easily give the DIV a unique ID, but do not know how I can call it from the jQuery if it is unique.

Any suggestions on the let case? :-)
Mar 9 '21 #3
Dormilich
8,651 Expert Mod 8TB
I can easily give the DIV a unique ID, but do not know how I can call it from the jQuery if it is unique.
Simply do not use ids when you don't need them.

Any suggestions on the let case?
If removing the ids doesn't help, try var.
4 Weeks Ago #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Ajai Kumar .R | last post: by
4 posts views Thread by bridgemanusa | last post: by
reply views Thread by question | last post: by
14 posts views Thread by =?Utf-8?B?UHVjY2E=?= | last post: by
1 post views Thread by 1sae | last post: by
13 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.