Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Show (a Region) IF recordset field = (value)

Guest
Apr 21, 2007 Apr 21, 2007
Hi -- I am working on ASP Javascript, and need to show a region if a recordset's column in my Access database shows a particular value. How do I write this? Thanks.
TOPICS
Server side applications
795
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Contributor , Apr 22, 2007 Apr 22, 2007
<% if (rs_SanFran.Fields.Item("OpenClose").value == "Open") { %>
Register now!
<% }else{ %>
Do something else
<% } %>
Translate
Contributor ,
Apr 22, 2007 Apr 22, 2007
<% if (rs.fields.item("field").value = "value") then %>
something to show
<% end if %>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 22, 2007 Apr 22, 2007
I get this error:

Microsoft JScript compilation error '800a03ec'
Expected ';'

pointing me to the line that has <% end if %> on it.

I put the code right into the part of the page where I want the information to appear if the column of the recordset is a particular value.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 22, 2007 Apr 22, 2007
sorry, that was in VB script.

try:

<% if (rs.fields.item("field").value == "value") { %>
something to show
<% } %>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 22, 2007 Apr 22, 2007
Thanks for getting back so fast...I feel like I'm working blindly here, so your help is greatly appreciated.

I got another error:

Microsoft JScript runtime error '800a01b6'
Object doesn't support this property or method

It specifies the line containing the IF statement. What does this error mean, and how can I fix? Am I doing right by putting it exactly in the page where I want the text to appear?

Thanks.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 22, 2007 Apr 22, 2007
Please provide the code block you are trying.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 22, 2007 Apr 22, 2007
ok, here's the code block -- thanks for your help.



<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" class="dottedlines" scope="row"><p class="subheader">San Francisco </p></td>
</tr>
<% while ((Repeat1__numRows-- != 0) && (!rs_SanFran.EOF)) { %>
<tr>
<td valign="top" scope="row"> <p> <strong><%=(rs_SanFran.Fields.Item("LocationName").Value)%></strong> <%=(rs_SanFran.Fields.Item("LocationDescription").Value)%><br>
<%=(rs_SanFran.Fields.Item("LocationDaysTimes").Value)%>
<br>
<% if (rs_SanFran.item("OpenClose").value == "Open") { %>
Register now!<% } %>

Sorry, this program is filled.

<p><br>
</td>
</tr>
<%
Repeat1__index++;
rs_SanFran.MoveNext();
}
%>
</table>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 22, 2007 Apr 22, 2007
You are forgetting the "Fields" method.

Change:
<% if (rs_SanFran.item("OpenClose").value == "Open") { %>
Register now!<% } %>

To:
<% if (rs_SanFran.Fields.Item("OpenClose").value == "Open") { %>
Register now!
<% } %>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 22, 2007 Apr 22, 2007
Oh, that did it thanks! I should have caught that.

Question: If I wanted to modify that to an IF THEN ELSE statement, how would I change that?

Thanks.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 22, 2007 Apr 22, 2007
<% if (rs_SanFran.Fields.Item("OpenClose").value == "Open") { %>
Register now!
<% }else{ %>
Do something else
<% } %>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 22, 2007 Apr 22, 2007
Thanks, that was it! Such a relief! I appreciate your time.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 24, 2007 Apr 24, 2007
LATEST
On a related note, how do I run an IF statement with a session variable?

I have pulled the variable from a list on a form on the preceding page. Everything works when a selection has been made from the drop-down list. However, if no selection has been made and the selected option, "Please select" value="none" is chosen, I get this error:
ADODB.Field error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

How do I fix this? Form validation isn't working, I'm guessing since it's an insert server behavior tied to the form.
Thanks.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines