-1

I created a variable and give it 0 let var = 0;

I want to change variable value by html input.

<input type="text" id="input" />

How can I do that 🤔

9
  • please read the stackoverflow tour before posting such questions. Commented Jul 12, 2021 at 17:15
  • <p><?php echo $VAR; ?></p> this is read steps thanks Commented Jul 12, 2021 at 17:17
  • code-boxx.com/display-php-variables-in-html Read and check this step in this website page. Commented Jul 12, 2021 at 17:18
  • @kuldeepraj the question doesn't mention PHP at all, so that's not relevant. Commented Jul 12, 2021 at 17:18
  • @WOUNDEDStevenJones he is asking how to render variable in html Commented Jul 12, 2021 at 17:19

1 Answer 1

0
<input id="myInput" type="text" onchange="changeV()">
...

let v = 0;
var changeV = ()=>{
    v = document.getElementById("myInput").value;
}

****And there's a serious error in your code. "let var = 0;" "var" is a keyword predefined in javascript. Specifically, it is a keyword used in variable declaration. Do not use predefined keywords as variable names.

Sign up to request clarification or add additional context in comments.

1 Comment

It doesn't work I use if condition when variable = 0 show input. and if it more than it show all project.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.