Tutorials
Show first [x] characters
You need to use the LEFT function in VBScript or the substring method of the String function in JavaScript.
VBScript
<%=LEFT(rsName.Fields.Item("MemoColumn").Value,100)%>
JavaScript
<%
var myString = (rsName.Fields.Item("MemoColumn").Value)
document.write(myString.substring(0,100))
%>
Notes
- rsName is the name of your recordset
- MemoColumn is the name of the column in your database that contains the text you only want the first [x] characters of.
- This code goes in the BODY of the page in the place you want to display the text.
- If you only wanted the first 20 characters, you should replace 100 in the code with 20.
You could combine this with the Maintain line breaks tutorial to make sure any line breaks in the first 100 characters are maintained.
© Copyright 2008 - robgt.com

