Solved

Right(string,1)

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
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…
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now