You need to use == or === for comparison instead of =.

  • x = y assigns y to x
  • x == y checks if y and x are loosely equal
  • x === y checks if y and x are equal and of the same type

So what you need to do is replacing if (hv.val = "1") with if (hv.val == "1")


you wrote

if (hv.val = "1")

but this is an assignment (evaluated as true, in your code): check for equality is == (equality by value) or === (equality by value and type)


you have used = operator which is used for assignment for comparison == operator is used try this In your if statement try this

if(hv.val=="1")