Home and Blog button

Pages

Introduction

Welcome To my Blog !!
This is a blog where you can get some knowledge that i have learned and been using. Sharing is gaining pals. So Happy Sharing and don't forget to follow and link my blog with yours! Thanks.
Happy Programming!!

Monday, October 19, 2009

Use of Slice() Function in Javascript!!

Use of Slice() Function in Javascript to get a portion of given text!!

Input Your Text Here:

Start:

End:



Source Code:

<html>
<head><title>Use of Slice() function!</title>
<script language="javascript">
function slicetxt() {
txtdisp.value=txtslice.value.slice(start1.value,end1.value);
}
</script>
</head>
<body>

Input Your Text Here: <input type="text" name="txtslice"><br>
Start:
<select name="start1">
<option value="-4">-4
<option value="-3">-3
<option value="-2">-2
<option value="-1">-1
<option value="0">0
<option value="1">1
<option value="2">2
<option value="3">3
<option value="4">4
</select> <br>

End: &nbsp;
<select name="end1">
<option value="-4">-4
<option value="-3">-3
<option value="-2">-2
<option value="-1">-1
<option value="0">0
<option value="1">1
<option value="2">2
<option value="3">3
<option value="4">4
</select>
<input type="button" name="bttnslice" value="Slice" Onclick="slicetxt()">
<input type="text" name="txtdisp" >
</body>
</html>

No comments:

Post a Comment

Search This Blog