function not repeating....

J

John Pether (john@

I have a repeater which displays the result of a recordset and a function which determins whether to display web or email link. It works but the function is not being repeated properly, the first record is being repeated for all results.....any help would be appreciated on how to overcome this....


I have the following function at the top of my page:
<%
strEmail = GetListings.Fields.Item("Email").Value
strWWW = GetListings.Fields.Item("WWW").Value
%>
<%
Function GetContactDetails( _
ByVal strEmail, _
ByVal strWWW _
)

If isNull(strWWW) then
If not isNull(strEmail) then
GetContactDetails = "<a href=""mailto:" & strEmail & "?subject=" & "Enquiry"">Email Us</a>"
Else
GetContactDetails = ""
End If
Else
If not isNull(strWWW) then
GetContactDetails = "<a href=""http://" & strWWW & """ target=" & "_blank"">Visit Us</a>"
End If
End If
End Function
%>

and then in the html I have a repeater:

<%
While ((Repeat1__numRows <> 0) AND (NOT GetListings.EOF))
%>
<tr>
<td valign="top"><strong><%=(GetListings.Fields.Item("BusinessName").Value)%></strong><br />
<%=(GetListings.Fields.Item("Address1").Value)%><%=(GetListings.Fields.Item("Address2").Value)%><br /> <%=(GetListings.Fields.Item("SubPost").Value)%><br /> </td>
<td valign="top"><%=(GetListings.Fields.Item("Phone").Value)%></td>
<td valign="top"><%=(GetListings.Fields.Item("Fax").Value)%></td>
<td valign="top"><%=GetContactDetails(strEmail, strWWW)%></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
GetListings.MoveNext()
Wend
%>

**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
 
R

Randy R

I think your problem is that you need to reset the values of strEmail and
strWWW before sending them to the function. It looks like you're setting
them outside the While Wend loop, so they're just keeping the values of the
first record. You need to put them inside the loop, so they pick up the
values of each record.


John Pether said:
I have a repeater which displays the result of a recordset and a function
which determins whether to display web or email link. It works but the
function is not being repeated properly, the first record is being repeated
for all results.....any help would be appreciated on how to overcome
this....
I have the following function at the top of my page:
<%
strEmail = GetListings.Fields.Item("Email").Value
strWWW = GetListings.Fields.Item("WWW").Value
%>
<%
Function GetContactDetails( _
ByVal strEmail, _
ByVal strWWW _
)

If isNull(strWWW) then
If not isNull(strEmail) then
GetContactDetails = "<a href=""mailto:" & strEmail & "?subject=" &
Enquiry"">Email Us said:
Else
GetContactDetails = ""
End If
Else
If not isNull(strWWW) then
GetContactDetails = "<a href=""http://" & strWWW & """ target=" &
_blank"">Visit Us said:
End If
End If
End Function
%>

and then in the html I have a repeater:

<%
While ((Repeat1__numRows <> 0) AND (NOT GetListings.EOF))
%>
<tr>
<td
<%=(GetListings.Fields.Item("Address1").Value)%><%=(GetListings.Fields.Item(
Address2").Value)%> said:
valign="top"> said:
<td valign="top"><%=(GetListings.Fields.Item("Fax").Value)%></td>
<td valign="top"><%=GetContactDetails(strEmail, strWWW)%></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
GetListings.MoveNext()
Wend
%>

**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP &
ASP.NET resources...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top