Logan Williams
Logan Williams

Reputation: 1

displaying a variable's value in a text box

var Stars = 0;

setText("Stars", Stars);

onEvent("FF1", "mouseover", function(event) {
  if (Star11 === true) {
    console.log("+1 star");
    var Stars = Stars + 1;
  }
  if (Star12 === true) {
    console.log("+1 star");
    var Stars = Stars + 1;
  }

I am trying to make a text box display the value of variable "Stars" after increasing that variable by 2. The text box is set at 0 and I am unable to get it to change based on the value of variable "Stars"

Edit: I have solved the issue

Upvotes: 0

Views: 654

Answers (1)

negool
negool

Reputation: 59

If I understood your question correctly, you can do something like this:

HTML:

<input id="stars" type="text" value=""/>
<button onclick="addStars()">
Click Me!
</button>

javaScript:

stars=0;
function addStars() {
    stars = stars + 1;
    document.getElementById("stars").value = "star "+ stars;
}

Upvotes: 1

Related Questions