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
11 Answers
+ 4
Good luck in programing! 😁
+ 4
inp.value is shorter.
As u like it.
What means "Ty"?
+ 3
document.getElementById(idOfInput).value
+ 3
It is abbreviated for thank you
+ 3
Ariela thanks )
+ 2
Place it in script tags below the html
+ 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 );
}
0
Ty ariela, do ive to place the script on a special place inside html5 code?
0
Ty very much Ariela
0
Ty mate, im gonna check that window.onload, just started programming 1 week ago :)
0
To work with the value is always through inp.value?