Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show full text if longer than field length value 1

Status
Not open for further replies.

kiwieur

Technical User
Apr 25, 2006
200
0
0
GB
Hi I am using the following function for limiting the amount of data that is shown in a table column with repeating region

Code:
<%
Function FieldCut (FCfield,FClength,FCtrimtype,FCtext) 
    if FCfield <> "" then
        if FCtrimtype = True then
            if LEN(FCfield) < FClength then
            FCfield = RIGHT(FCfield, FClength)
            Else
            FCfield = RIGHT(FCfield, FClength) & FCtext
            End if
        Else
            if LEN(FCfield) < FClength then
            FCfield = LEFT(FCfield, FClength)
            Else
            FCfield = LEFT(FCfield, FClength) & FCtext
            End if
        End if            
    Response.Write(FCfield)
    End if
End Function
'***EndFieldCut- control output
%>

And I am using it on the following field
Code:
<%=FieldCut((rsOldStock.Fields.Item("Comments").Value),20,false,"")%>

However what i would like to do is if the text is longer than the specified amount, in this case it is 20 characters I would like a way to show the users the full text.

I have actually done the following
Code:
<td class="TextNormalRight">
	  <A HREF="RepsComments.asp?<%= Server.HTMLEncode(MM_keepNone) & MM_joinChar(MM_keepNone) & "PlantID="&(rsOldStock.Fields.Item("PlantID").Value)& "&Spec_No="&(rsOldStock.Fields.Item("Spec_No").Value) %>"><%=FieldCut((rsOldStock.Fields.Item("Comments").Value),20,false,"")%></A></td>
which when the user clicks on the comments field it takes them to another page where they can see all of the text.

What I would really like to do is say if the field length is greater than 20 then show the link otherwise there is no link.

Can anyone suggest a way to accomplish this please

[ponder]



Regards

Paul

 
lil psuedocode for you here, forgive me i'm feeling slightly lazy today. break it into functions as you see fit

if len(rs(field)) => 20 then
response.write left(rs(field),20) & "<a href='whatever.asp?refid=" & rs(idfield) & "'>...</a>"
else
response.write rs(field)
end if


personally i'm lazy i do this:

if len(rs(field)) => 20 then
response.write "<a title='" & Server.HTMLEncode(rs(field)) & "'>" & left(rs(field),20) & "...</a>"
else
response.write rs(field)
end if

then on mouseover it shows the text


[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
" I always think outside the 'box', because I'm never inside the 'loop' " - DreX 2005
 
Hi Robert,
Thank you for replying and for the code you supplied. i have changed my code now to this
Code:
      <td class="TextNormalLeft">
<% if len(rsOldStock.Fields.Item("Comments")) => 21 then %>
<%response.write "<a title='" & (rsOldStock.Fields.Item("Comments")) & "'>" & left(rsOldStock.Fields.Item("Comments"),20) & "...</a>"%>
<%else%>
<%response.write (rsOldStock.Fields.Item("Comments"))%>
<%end if%>
</td>

and "Voila" works perfectly a "star" for you

[thumbsup][bigsmile][thumbsup]

Regards

Paul

 
dont forget to do handling on the title, the reason being is if u dont it can break your html with things as simple as a quote i usually use htmlencode

[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
" I always think outside the 'box', because I'm never in the 'loop' " - DreX 2005
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top