0
Javascript access form values
Hi guys i have a problem in my code. i don't how to access the value in js code that i enter in my forms and store them in variables https://code.sololearn.com/WFrHDCpul4SB/?ref=app
10 odpowiedzi
+ 3
Use setValues() as the handler for the main form's submit event.
<form onsubmit="setValues()">
+ 2
It is quit simple target the input element of which you want to get the value
By using
1. document.getElementById("id_name")
2. document.getElementsByClassName("class_name")
The fetch the value using .value
Final syntex
1. document.getElementById("id_name").value
2. document.getElementsByClassName("class_name").value
Store it Into variables and use them
+ 2
No problem bro 👌
+ 1
乂丹ⓨㄩک廾乂〖թг๏〗 if you see my code it's the same logic I used that you tell me but my code not give value on the console
+ 1
Saad Mughal
Bro I meant the form on line 24 ...
+ 1
Ipang thank you 😁
+ 1
All the attributes in The very first "div" in the "form" tag should be in the "form" tag and not the "div" tag, that should fix it.
0
Ipang check I already use setvalue in onsubmit but I didn't console the values
0
Hey man!!!
You have call your setvalues fxn with event onsubmit on a div !!
I mean how can you submit a div!!🙄😵
I think it should be on form tag .
actually you have set all attributes of form to that div..
just transfer all attributes to form it will work as u want.