63Views2Replies

Author Options:

help with javascript? Answered

Hello, i just want to know how to change a variable's value permanently in a java script file using an input field. like i created a variable: Now the script displays you have 20 cars then i want to change that number-of-cars variable while staying on the page it means i want to modify the file and change the number of cars in that variable through an input box! Please help me with this!

Discussions

The forums are retiring in 2021 and are now closed for new topics and comments.
0
Libahunt
Libahunt

Best Answer 6 years ago

Your description of the problem needs clarification.
What variable? Javascript variable? Or backend/database? Or HTML output?

For javascript variable could use onchange event of the input field http://www.w3schools.com/jsref/event_onchange.asp

That assigns a new value any time a character is typed into or deleted from the input box.

0
mh76dk
mh76dk

6 years ago

To change the size (lenght) of an input field you need to change the HTML (see:

http://www.w3schools.com/tags/att_input_size.asp ). Though it is possible to do with CSS (cascading style sheets) or dynamically with Javascript - The easy way if you are a beginner would be to set it in HTML - You can alsways do it in a different way when/if you get more comfortable with the languages you use.

And here is a discussion on how to get the value of the input field into a variable in javascript: http://stackoverflow.com/questions/3547035/javascr...