I have a form with two inputs fields.
<form action="file.js" method="post" class="FormData">
<div>
<p>Year</p>
</div>
<div>
<input type="number" name="Year"></input>
</div>
<div>
<p>Name</p>
</div>
<div>
<input type="text" name="Tvshow"></input>
</div>
<div>
<button class="btn">Send</button>
</div>
</form>
On the one hand Year field will obtain year chosen by user to show any tvshow and tvshow field will save tvshow name to show it base on moviedb Api request.
This is my javascript code:
const callbackYear = Year_User =>
{
Year_User(Year);
}
const callbackTvshow = show =>
{
show(name)
}
const getData = () => {
const button = document.querySelector(".btn");
button.addEventListener("click", () => {
const Form = document.querySelector(".FormData");
const Year = new FormData(Form).get("Year");
const name = new FormData(Form).get("Tvshow");
callbackYear(Year);
callbackTvshow(name);
});
}
callbackYear((Year_User) =>
{
console.log(Year_User);
})
callbackTvshow((show) =>
{
console.log(show);
})
Basically what I'm trying to do is to get both data (Year and Tvshow name) with two severals callbacks called Year_User and show to make an statement between the two callbacks.
Something like this:
//Example
callbackYear((Year_User) =>
{
if(Year_User!=undefined)
{
callbackTvshow((Tvshow) =>
{
//Code
})
}
})
Maybe it could be more clearly now with this example.
Please help!