I was wondering if it is possible to get the first number of a bigger number. For instance when a variable is 2674, that I can store the first number (in this case "2") and store it in another variable. Thanx in advance!, Zynex
var num = 2674; var first = num.toString().substr(0, 1); Code (javascript): EDIT: Or: var first = num.toString()[0]; Code (javascript):
<script type="text/javascript"> var str="2674" var shortStr = str.substring(0,1); </script> Code (markup): Try above code. but keep it mind, var str should be string.