Skip to main content
juresti
Known Participant
February 24, 2011
Answered

VB If statement for repeating region

  • February 24, 2011
  • 1 reply
  • 1182 views

Basically Im trying to show different code if the value in the DB in column Format is "View" or "Download" in bold is what I did my I'm thinking the code is wrong. I made one recordset named Umm. Any help is appreciated.

<table class="sortable" id="sortabletable" width="900" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <th width="260">Division</th>
        <th width="226">Title</th>
        <th width="108">Format</th>
        <th width="148">Language</th>
      </tr>
      <% While ((Repeat2__numRows <> 0) AND (NOT Umm.EOF)) %>
        <tr>
          <td><%=(Umm.Fields.Item("Division").Value)%></td>
          <td><%=(Umm.Fields.Item("Title").Value)%></td>

<% if (Request.QueryString("Format")) = "Download" then %>
         
          <td><a href="<%=(Umm.Fields.Item("URL").Value)%>"><%=(Umm.Fields.Item("Format").Value)%></a></td>

<%elseif (Request.QueryString("Format")) = "View" then%>
            <td><a href="javascript:;" onclick="MM_openBrWindow('<%=(Umm.Fields.Item("URL").Value)%>','','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=600')"><%=(Umm.Fields.Item("Format").Value)%></a></td>

<% end if %>  
         
          <td><%=(Umm.Fields.Item("Language").Value)%></td>
        </tr>
        <%
  Repeat2__index=Repeat2__index+1
  Repeat2__numRows=Repeat2__numRows-1
  Umm.MoveNext()
Wend
%>
    </table>

This topic has been closed for replies.
Correct answer bregent

I created the recordset and need all columns, but if the Format column has a value of View

I want certain HTML written:

<% if (Request.QueryString("Format")) = "Download" then %>
         
          <td><a href="<%=(Umm.Fields.Item("URL").Value)%>"><%=(Umm.Fields.Item("Format").Value)%></a></td>

<%elseif (Request.QueryString("Format")) = "View" then%>
            <td><a href="javascript:;" onclick="MM_openBrWindow('<%=(Umm.Fields.Item("URL").Value)%>','','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=600')"><%=(Umm.Fields.Item("Format").Value)%></a></td>

What do I need to use instead of Request.QueryString? Hmm I will research.


QueryString is used to get the querystring in the url. You want to compare a value in the database column:

<% if Umm.Fields.Item("Format").Value = "Download" then %>
         
etc.....

1 reply

Participating Frequently
February 24, 2011

Is there a problem? What are the symptoms? I see a possible typo with a space character in "Format" but not sure if this is just a cut and paste issue in your post. There could be other problems but it's hard to tell when we don't know what problem you are experiencing.

<td><a  href="<%=(Umm.Fields.Item("URL").Value)%>"><%=(Umm.Fields.Item("Forma  t").Value)%></a></td>

juresti
jurestiAuthor
Known Participant
February 24, 2011

The problem is the HTML is not written for either IF or Else If. How does Request Query know where to get the information from?

Participating Frequently
February 24, 2011

Request Query? Do you mean Request.QueryString? It gets the name/value pair from the querystring collection. Can you give us an example of what your url/querystring looks like?

Is your condition based on a querystring value or a database value?