Is there a javascript equivalent of vb's right() function please ???
Printable View
Is there a javascript equivalent of vb's right() function please ???
Without looking... I'm thinking you can get the last five characters of a string like this:
I could just be thinking of Perl or something. Too many languages.Code:var myString = "Hello, Mother";
var myRightString = myString[-5..0];
Ah, sorry, here, try this...
Code:<html>
<head></head>
<body>
<p>
<script type="text/javascript">
var myString = "Hello, Mother";
document.write(myString.substring(myString.length - 5, myString.length));
</script>
</p>
</body>
</html>
nope ;)
next ...
ah, that second one did the trick - thanks ;)
there is no built in Right() function, but you can make your own easily.
:)Code:function right(str, intSpaces)
{
return str.substr(str.length - intSpaces, str.length)
}
looks like I'm a tad late :rolleyes: