Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
13
rated 0 times [  20] [ 7]  / answers: 1 / hits: 114424  / 9 Years ago, thu, june 25, 2015, 12:00:00

Let's say I have a variable called x in javascript. How can I set the value of a text input (HTML) to that variable? For example:



The value of the input will now be Swag



<input type=text value=Swag />


But if I want the value to be a javascript variable? How do I do? Something like this? (I am just guessing, trying to make my point clear)



<input type=text value=variable.x />

More From » html

 Answers
7

You can set it in your javascript code like:



<input id=myInput type=text value=Swag />

<script>
var test = test;
document.getElementById(myInput).value = test;
</script>

[#66047] Wednesday, June 24, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
malkajillc

Total Points: 652
Total Questions: 107
Total Answers: 98

Location: Finland
Member since Sat, Nov 6, 2021
3 Years ago
malkajillc questions
;