Thursday, March 15, 2012

cut string in JavaScript using substr function

String : HH:MM:AMPM


syntex : 


var cutstr = string.substr(startIndex , Length) ; 


CODE :- 
<script>
function cutstring(){

btime = 'HH:MM:AMPM ';

var hh = btime.substr(0,2);
var mm = btime.substr(3,2);
var ampm =btime.substr(6,2);
alert(hh);
alert(mm);
alert(ampm);

}
</script>
<b> String :  HH:MM:AMPM </b>
<input type="button" onclick="cutstring()" name="button" value="click " />

No comments:

Post a Comment

If you Satisfied , Please Leave a comment