Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Right(string,1)

Posted on 2004-04-26
3
Medium Priority
?
12,879 Views
Last Modified: 2007-11-27
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
Comment
Question by:Pyro-San
  • 2
3 Comments
 
LVL 33

Expert Comment

by:hongjun
ID: 10924492
var str = "abcdefg";
var str3 = str.substring(str.length-3);  // pull out right 3


hongjun
0
 
LVL 33

Accepted Solution

by:
hongjun earned 200 total points
ID: 10924504
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
 

Author Comment

by:Pyro-San
ID: 10924532
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question