-1

I am trying to match javascript variable value with value taken from scriptlet in jsp but even value are same I am not getting result true.

var a = 1;
console.log(a == <%=Constants.SOME_CONSTANT_VALUE%>);

Here value of Constants.SOME_CONSTANT_VALUE is "1" [String type] but I am getting console output as false.

Naveen Ramawat
  • 1,425
  • 1
  • 15
  • 27

2 Answers2

1

try console.log(a == "<%=Constants.SOME_CONSTANT_VALUE%>");

mmk
  • 480
  • 3
  • 10
  • Please try assigning scriptlet value to javascript var and then try to compare both javascript vars. Before comparing, plz check both javascript vars should output same value. – mmk Nov 30 '15 at 10:10
  • Hi There was fault in my code. Now it is working :) .. accepting the answer .. thanks .. – Naveen Ramawat Nov 30 '15 at 10:22
0

Use parseInt and compare like below:

console.log(a == parseInt(<%=Constants.SOME_CONSTANT_VALUE%>));
Miguel
  • 536
  • 6
  • 20