Solved

Right(string,1)

Posted on 2004-04-26
3
12,876 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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

622 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