• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 12882
  • Last Modified:

Right(string,1)

how do I select the right char of a string in an input=text?

elem[i].value

something like

Right(elem[i].value, 1)
but it has to be in javascript not VB
it is for an asp document.
0
Pyro-San
Asked:
Pyro-San
  • 2
1 Solution
 
hongjunCommented:
var str = "abcdefg";
var str3 = str.substring(str.length-3);  // pull out right 3


hongjun
0
 
hongjunCommented:
i think this looks better :)

<script language="JavaScript">
function Right(str, num)
{
      return str.substring(str.length-num);  // pull out right num
}

var str = "abcdefg";
alert(Right(str, 3));
</script>



hongjun
0
 
Pyro-SanAuthor Commented:
yeah, top one was what I was after but bottom one looks a lot better and is more functional :)
damm js for not having a funtion already
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now