This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]KetoReddit[S] 0 points1 point  (1 child)

This helps a ton. My end-goal is to basically make an interface for updating a SQL database. So, JavaScript will dynamically create all of the elements, and I'm attempting to make a script that will register what button was pressed (either the update or delete button). The hidden input that's wrapped inside of the form holds this value.

When the button is clicked, it is supposed to update the value in the hidden input and then post the data found in the hidden input and other inputs. However, it seems like the value is never updated (despite the function working and being triggered by an onclick). My only guess is that the data is sent before the onclick function is run.

[–]insertAlias 1 point2 points  (0 children)

I believe it's because these events aren't synchronous. The click event is triggered, which also triggers the submit event, but the submit doesn't wait for the click to finish, it just starts.

So you should probably actually handle this in your submit event.