I am trying to Recieve both form data in single click which is create button.
Asked
Active
Viewed 106 times
-2
-
Possible duplicate of https://stackoverflow.com/questions/7843355/submit-two-forms-with-one-button? – Puneet Feb 10 '23 at 07:21
1 Answers
0
I assume you're using reactjs
and know useRef
. You can use useRef
to reference those two submit buttons from different forms. First you need to create a variable
const buttonRef = useRef()
Now you have to add ref={buttonRef}
to both of those button tags as an attribute. Lastly, you have to add a function that triggers those button clicks. You can add onClick
attribute to Create button. You can add this to Create button onClick={() => buttonRef.currentRef.click()}
.
These steps will let you submit two form. But won't merge two form data into one.

Abid Hasan
- 58
- 3