| Author: Varun Bansal 11 Oct 2008 | Member Level: Gold | Rating: Points: 6 |
use this code..
function getcommission() { var sp,len,size; var comm; comm="hari;(5.7%)"; sp=Number(comm.indexOf("(")) + 1; len=comm.length; size = len - 2; comm= comm.substring(sp,size); // sp is starting index and size is end index alert(comm); return comm; }
output is 5.7
|
| Author: Meetu Choudhary 11 Oct 2008 | Member Level: Gold | Rating: Points: 4 |
To get the substring in JavaScript you can use the following code
function getSubstring() { var index,len; var str; str="MyString"; sp=str.indexOf("S"); len=str.length; var leng = 6; str= str.substring(index,leng); // index is starting index and leng is the length alert(str); return str; }
-- thanks and regards Meetu Choudhary
|