Solved

Right(string,1)

Posted on 2004-04-26
3
12,871 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 50 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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

770 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