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

6th Aug 2020, 8:24 AM
Saad Saleem
Saad Saleem - avatar
10 Réponses
+ 3
Use setValues() as the handler for the main form's submit event. <form onsubmit="setValues()">
6th Aug 2020, 8:41 AM
Ipang
+ 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
6th Aug 2020, 8:38 AM
Ayush Kumar
Ayush Kumar - avatar
+ 2
No problem bro 👌
6th Aug 2020, 8:54 AM
Ipang
+ 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
6th Aug 2020, 8:48 AM
Saad Saleem
Saad Saleem - avatar
+ 1
Saad Mughal Bro I meant the form on line 24 ...
6th Aug 2020, 8:52 AM
Ipang
+ 1
Ipang thank you 😁
6th Aug 2020, 8:54 AM
Saad Saleem
Saad Saleem - avatar
+ 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.
7th Aug 2020, 4:08 PM
Israel Edoghama
Israel Edoghama - avatar
6th Aug 2020, 8:27 AM
Saad Saleem
Saad Saleem - avatar
0
Ipang check I already use setvalue in onsubmit but I didn't console the values
6th Aug 2020, 8:49 AM
Saad Saleem
Saad Saleem - avatar
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.
6th Aug 2020, 10:01 AM
Divya Mohan
Divya Mohan - avatar