0

getElementById

Hi ppl, i wanna get the string entered by user in a html5 form and use it in a script, im new programming but i think it has to be using getElementById but i cant make it work. Could u guys show me one example? Ty in advanced

11th Apr 2018, 9:51 PM
Juanma De la Flor
Juanma De la Flor - avatar
11 Answers
+ 4
Good luck in programing! 😁
11th Apr 2018, 11:04 PM
Сергей Луньков
Сергей Луньков - avatar
+ 4
inp.value is shorter. As u like it. What means "Ty"?
11th Apr 2018, 11:14 PM
Сергей Луньков
Сергей Луньков - avatar
+ 3
document.getElementById(idOfInput).value
11th Apr 2018, 9:55 PM
Ariela
Ariela - avatar
+ 3
It is abbreviated for thank you
11th Apr 2018, 11:26 PM
Ariela
Ariela - avatar
+ 3
Ariela thanks )
11th Apr 2018, 11:32 PM
Сергей Луньков
Сергей Луньков - avatar
+ 2
Place it in script tags below the html
11th Apr 2018, 10:07 PM
Ariela
Ariela - avatar
+ 2
Juanma De la Flor U must to place the code after HTML element with this id or on JS tab put into function and to set in the body tag event handler "onload", either call function with event handler "window.onload" directly JS tab. Also u can get access by id if script locate below of element or after "window.onload" handler on JS tab. Example: <input id="inp" value="some text"/> <script> alert( inp.value ); </script> P.S. On js tab window.onload=function ( ) { alert ( inp.value ); }
11th Apr 2018, 10:38 PM
Сергей Луньков
Сергей Луньков - avatar
0
Ty ariela, do ive to place the script on a special place inside html5 code?
11th Apr 2018, 10:00 PM
Juanma De la Flor
Juanma De la Flor - avatar
0
Ty very much Ariela
11th Apr 2018, 10:09 PM
Juanma De la Flor
Juanma De la Flor - avatar
0
Ty mate, im gonna check that window.onload, just started programming 1 week ago :)
11th Apr 2018, 11:01 PM
Juanma De la Flor
Juanma De la Flor - avatar
0
To work with the value is always through inp.value?
11th Apr 2018, 11:10 PM
Juanma De la Flor
Juanma De la Flor - avatar