C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




use substring function in javacript


Posted Date: 11 Oct 2008      Total Responses: 2

Posted By: bansal007       Member Level: Bronze     Points: 1


hi,

i want to use substring funtion in javascript..
please tell me how...






Responses

Author: Varun Bansal    11 Oct 2008Member Level: GoldRating:     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 2008Member Level: GoldRating:     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



Post Reply
You must Sign In to post a response.
Next : checkbox and Gridview
Previous : timer Control
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

email fax service

Contact Us    Privacy Policy    Terms Of Use