0

All I need is to compare a given number vs a fixed number, and if it true, return one paragraph and if not true, return an alternative paragraph. I have no ASP experience, and minimal html skill.

I have a changing dollar figure in a database field called [now list]; and this field has been formatted as currency.

I want the page to evaluate whether or not [now list] is > or < 5 (or 10, or 20 or any numeral); but for now let's just evaluate against the number 5.

I turn my webpage into html code that I can edit. I tried this:

IF [now list]<5, 
    then "write this big paragraph which may or may not include lots of html links" 
    else "write different paragraph I can make up to suit me."     
ENDIF

If [now list] < 5, THEN write big, ELSE write different. 

I have the idea that this code will go on the page in the place where I want the paragraph to show up, regardless of which paragraph gets picked? Right? When I tested the page, it shows the IF statement written out, not the result of the analysis I'd hoped for.

Please help me. For my benefit, please pretend I am a bright 7-yr old kid; even though I am 57. Thanks in advance.

aircraft
  • 25,146
  • 28
  • 91
  • 166
  • I display the value of this price elsewhere in the sheet by using this method: <% =FormatCurrency(rs("Now List"), 0) %> which shows the value as whole dollars. I don't know if this is relevant, but thought I'd include it anyway. – Steve Freeman Mar 16 '17 at 00:40

1 Answers1

0

You need to make sure to wrap your code in the standard ASP.NET markup, <% and %> tags. These tags tell the page to render what it's about to read as ASP.NET rather than HTML (the default). The tags will get invisibly stripped from the output, and only the contents of the ASP.NET code will execute.

In addition to this, while you would typically think to only run your code within a set of these tags, you can actually 'break out' of the code logic while still inside an ASP.NET conditional:

<% if(now_list < 5) { %>

<a href="link1.html">Link 1</a>
<a href="link2.html">Link 2</a>
<a href="link3.html">Link 3</a>

<% } else { %>

<p>Different HTML code</p>

<% } %>

In the above example, a number of links will output when now_list is less than 5, and Different HTML code will output when it is equal to or greater than 5.

Hope this helps! :)

Obsidian Age
  • 41,205
  • 10
  • 48
  • 71
  • Looked promising, but didn't work. and I've never seen the little underscores and carat like this before. I tried several variants on the "now list" field name, which unfortunately does have a space in-between words. I did not try to use the underscore between "now" and "list" as you suggested though. My latest attempt was this: <% if([now list] < 5) { %>

    This is a Sheriff Sale. Use this information at your own risk.

    <% } else { %>

    Big essay paragraph

    <% } %>
    – Steve Freeman Mar 16 '17 at 13:39
  • My latest attempt was this: <% if([now list] < 5) { %>

    This is a Sheriff Sale. Use this information at your own risk.

    <% } else { %>

    Big essay paragraph

    <% } %> and I thought this would be a good preliminary testing of the solution. This did not work. I tried various bracketing around "now list" such as [] and (), to no effect.
    – Steve Freeman Mar 16 '17 at 13:41
  • The SQL that extracts "now list" info is here (in part) which I don't know if it's helpful or not; but it's what I'm working with here. These fields are being extracted from a database table named "FREIS". cn.Open GetConnString() Dim sSQL sSQL = "SELECT subdiv, design, legal, exterior, asfla, " & _ "ptype, [year built], SaleDate, [Sale P$], fin, status, source, "lotdim, idno2, idno, nr1, news, street, [now list], [seller assistance], icode, cars, " & _ [4th br dim], [a/c], tax " & _ "FROM [FREIS] " & _ "WHERE idno = " & Request("id") – Steve Freeman Mar 16 '17 at 13:42
  • You can see where "now list" comes in enclosed in brackets []. The database from which it comes shows this as a number, format=currency, decimal places=0, field size=double. ..... Makes me wonder if the "5" value I am using needs to be changed to "$5" to match currency vs currency? I'm clueless really. – Steve Freeman Mar 16 '17 at 13:45
  • Please visit Freisco.com, select "Find Homes", login using "overflow" and "ftphelper"; look in Brownstown township, select S properties, price $1 to $10000; hit return, taken to roster. Select one from roster. This will show error. On this page, right-click select view source. I am trying to make this paragraph insertion operation occur on line 95. .... You can find an A=available home, same township, priced 100-150K, see roster, select one from roster, and see "no if statement" result, the normal result. I am trying to toggle paragraph alongside my picture. – Steve Freeman Mar 16 '17 at 13:58