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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

response is undefined

Status
Not open for further replies.

anpfire

Programmer
Oct 8, 2003
22
CA
Hi,
I am creating a dynamic table and would like to display a hyperlink depending on whether or not there is a value in the database.

This is the code I have:
<table border=&quot;1&quot; bordercolor=&quot;#417A98&quot; width=&quot;350&quot; align=&quot;center&quot;>
<% while ((Repeat1__numRows-- != 0) && (!Rset.EOF)) { %>
<tr>
<td><%=(Rset.Fields.Item(&quot;Authors&quot;).Value)%> </td>
<td><%=(Rset.Fields.Item(&quot;Title&quot;).Value)%> </td>

<td>
<%
if ((TableRecordset.Fields.Item(&quot;Link&quot;).Value) != &quot;&quot;)
{
response.write(&quot;<a href=&quot;);
%>
<%=(TableRecordset.Fields.Item(&quot;Link&quot;).Value)%>
<%
response.write(&quot; target=_blank>View PDF doc</a>&quot;);
}
else
{
response.write(&quot; &quot;);
}
%>
&nbsp;
</td>
</tr>
<%
Repeat1__index++;
TableRecordset.MoveNext();
}
%>
</table>

I would like to display &quot;View PDF doc&quot; as text for the hyperlink if Item(&quot;Link&quot;).Value has a value. If it has no value, nothing should be displayed. The problem is that I am getting a runtime error - response is undefined. How can I solve this? I appreciate any suggestions. Thanks.
Anoop.
 
<%=(TableRecordset.Fields.Item(&quot;Link&quot;).Value)%>

should be

<%=(Rset.Fields.Item(&quot;Link&quot;).Value)%>



Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
I had changed TableRecordset to Rset. But the &quot;response is undefined&quot; error still comes up!
 
What line is throwing the error?

Try placing

response.flush

statements throughout the output and see what makes it and what doesn't...

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
This is the error that comes up:

Error Type:
Microsoft JScript runtime (0x800A1391)
'response' is undefined

It is for line:
response.write(&quot;<a href=&quot;);

I placed response.flush before this line and got the same error. It doesn't recognize &quot;response&quot; at all.
 
Does this throw the same error?

<%
if ((Rset.Fields.Item(&quot;Link&quot;).Value) != &quot;&quot;)
{
response.write(&quot;<a href='&quot;);
response.write(Rset.Fields.Item(&quot;Link&quot;).Value);
response.write(&quot;' target='_blank'>View PDF doc</a>&quot;);
}
else
{
response.write(&quot; &quot;);
}
%>

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
Yes, the same error comes on the line:
response.write(&quot;<a href='&quot;);
 
does it run if you comment out the line? Keep commenting out lines until you find the culprit...

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
I started commenting out lines and I found that the error only comes up when repsonse is written within the &quot;if&quot; brackets. When response is written within the &quot;else&quot; brackets, no error comes up.

So I changed the if-else statement to this:

if ((Rset.Fields.Item(&quot;Link&quot;).Value != &quot;&quot;))
{
// response.write(&quot; &quot;);
}
else
{
response.write(&quot;<a href='&quot;);
response.write(Rset.Fields.Item(&quot;Link&quot;).Value);
response.write(&quot;' target='_blank'>View PDF doc</a>&quot;);
}

This does not give any runtime error. but it does not do anything. I changed the &quot;!=&quot; to &quot;==&quot; in the if statement, and the &quot;response is undefined&quot; error came again! I think something is wrong with the if statement.
 
hmm - is Rset.Fields.Item(&quot;Link&quot;).Value null?

Change your select to this..


&quot;select field1, field2, isNull(link,'') from myTable&quot;

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
I got this error from the select statement:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Wrong number of arguments used with function in query expression 'isNull(Link,'')'.
 
I found the problem. If Statement is fine.
response.write(&quot;&quot;) was incorrect.

It had to be:
Response.Write(&quot;&quot;) - Capital letters!!!

After I changed that, everything worked.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top