Extracting long articles from the database always hinders the layout of the web page.
[Ctrl+A Select all Note: If you need to introduce external Js, you need to refresh to execute]
left(): Intercept the first part of a string
[Ctrl+A Select all Note: If you need to introduce external Js, you need to refresh to execute]
3. Main program: determine whether the content length is greater than the given value, and perform corresponding operations based on the results.
[Ctrl+A Select all Note: If you need to introduce external Js, you need to refresh to execute]
4. Application in ASP
The above is in client script debugging, which is similar to ASP: the most important thing is the function function.
<% text=rs("content")' Assign the database field value to a variable i=10' defines a fixed size iflen(text)> ithen' if the text length is greater than the given value text=left(text,i)' then extracts the i-bit string in the previous section response.write(text&"...") else response.write(text) endif %> |
5. For convenience, make a function
<% functionconleft(content,i) iflen(content)> ithen content=left(content,i) response.write(content&"...") else response.write(content) endif endfunction %> |
The above is a function, and you can call it directly below.
<%callconleft(rs("content"),10)%> |
OK, I believe that these problems should be NOPROBLEM