Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Dynamic IF Statement?!?!?HELP

  • 13-06-2011 10:54AM
    #1
    Registered Users, Registered Users 2 Posts: 224 ✭✭


    Hi,

    I have a dynamically driven site and am having an issue with an IF statement.

    Basically I want the page to write a frameset depending if a record ("TotalQTY") equals "1" Else if it doesnt, it remains blank.

    Im using ASP VBScript and SQL Server DB.

    Any help would be much much appreciated.

    Sorry i posted this on the wrong forum, i hope i got the right one now:eek:


Comments

  • Registered Users, Registered Users 2 Posts: 2,781 ✭✭✭amen


    you really need to post some code that you have tried to get working.

    This will help us to point you in the right direction.


  • Registered Users, Registered Users 2 Posts: 3,721 ✭✭✭E39MSport


    Bit vague but perhaps a case would help?

    CASE
    WHEN TotalQTY=1 THEN 'something'
    ELSE 'Dont'
    END AS WHATEVER


  • Registered Users, Registered Users 2 Posts: 224 ✭✭The Mighty Dubs


    OOPS! Will this do the trick
    **************
    <%
    Dim recordset
    Dim recordset_cmd
    Dim recordset_numRows

    Set recordset_cmd = Server.CreateObject ("ADODB.Command")
    recordset_cmd.ActiveConnection = strConnection
    recordset_cmd.CommandText = "SELECT * FROM dbo.qryViewListItems WHERE ProdID = ?"
    recordset_cmd.Prepared = true
    recordset_cmd.Parameters.Append recordset_cmd.CreateParameter("param1", 5, 1, -1, recordset__MMColParam) ' adDouble

    Set recordset = recordset_cmd.Execute
    recordset_numRows = 0
    %>

    <!-- Write the following if <%=(recordset.Fields.Item("TotalQty").Value)%> <> "0" -->

    <fieldset class="fieldset1" style="width:780px; height:inherit; border:2px solid #00addf; ">
    <legend> Do you want to put this item On Hold?  </legend>
    <form ACTION="<%=MM_editAction%>" name="frmQuarantine" method="POST" >
    <table width="100%" cellspacing="2" cellpadding="2">
    <tr class="tbl-head">
    <td width="7%" align="center">Brand</td>
    <td width="12%" align="center">PfizerItemID</td>
    <td width="55%" align="center">Description</td>
    <td width="11%" align="center">Total Stock</td>
    <td width="10%" align="center">Total Released</td>
    <td width="10%" align="center">Total Qty On Hold</td>
    <td width="5%" align="center">Qty To Put On Hold</td>
    </tr>
    <tr class="tbl-row">
    <td align="center" bordercolor="#333333"><img src="siteimgs/brands/<%=(recordset.Fields.Item("brandlogo").Value)%>" /></td>
    <td align="center" bordercolor="#333333"><%=(recordset.Fields.Item("PfizerItemID").Value)%></td>
    <td align="left" bordercolor="#333333"><%=(recordset.Fields.Item("ProdDesc").Value)%></td>
    <td align="center" bordercolor="#333333"><%=(recordset.Fields.Item("TotalQty").Value)%></td>
    <td align="center" bordercolor="#333333"><% response.write(GetReleasedStock(rsReleaseOnHold))%></td>
    <td align="center" bordercolor="#333333"><%=(recordset.Fields.Item("QTYONHOLD").Value)%></td>
    <td align="center" bordercolor="#333333">
    <input name="QtyOnHold" type="text" id="QtyOnHold" value="<%=(recordset.Fields.Item("QTYONHOLD").Value)%>" />
    </td>
    </tr>
    <tr class="tbl-row">
    <td colspan="6" align="center" class="tablerepeatrow"><table width="100%" border="0" cellspacing="3" cellpadding="3">

    <tr class="tbl-row">
    <td><label>Comments </label></td>
    <td><textarea name="ItemComments" id="ItemComments" cols="45" rows="5"> <%=(recordset.Fields.Item("ItemComments").Value)%></textarea></td>
    </tr>
    </table></td>
    </tr>
    <tr class="tbl-row">
    <td colspan="6" align="center"><input type="reset" name="button" id="button3" value="Reset" />
    <input type="submit" name="button" id="button4" value="Submit" />
    <input name="OnHold" type="hidden" id="OnHold" value="1" /></td>
    </tr>
    </table>
    <input type="hidden" name="MM_update" value="frmQuarantine" />
    <input type="hidden" name="MM_recordId" value="<%= recordset.Fields.Item("ProdID").Value %>" />
    </form>
    </fieldset>


  • Registered Users, Registered Users 2, Paid Member Posts: 2,032 ✭✭✭lynchie


    Been a while since I done vb but will the following not work?

    <%

    if recordset.Fields.Item("TotalQty").Value <> 0

    %>

    <fieldset .......
    .
    .
    .
    </fieldset>

    <%
    end if
    %>


  • Registered Users, Registered Users 2 Posts: 15,079 ✭✭✭✭Malice


    Whatever about the rest of the solution I'd recommend that you change this
    recordset_cmd.CommandText = "SELECT * FROM dbo.qryViewListItems WHERE ProdID = ?"

    to only return the columns you need. Seeing "SELECT *" statements in production code annoys me.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 2,494 ✭✭✭kayos


    Malice wrote: »
    Whatever about the rest of the solution I'd recommend that you change this



    to only return the columns you need. Seeing "SELECT *" statements in production code annoys me.

    Or go one futher and move the query into a SP...

    I had forgotten what a wall of text ASP was.


  • Registered Users, Registered Users 2 Posts: 15,079 ✭✭✭✭Malice


    kayos wrote: »
    Or go one futher and move the query into a SP...
    Good point.
    kayos wrote:
    I had forgotten what a wall of text ASP was.
    Things like avoiding a table-based layout and keeping styling in a CSS file will help to a certain extent but it is definitely a shock to the system if you wind up maintaining something like this if you've had any exposure to a project where data access, code and presentation are kept apart.


  • Posts: 0 ✭✭✭ [Deleted User]


    My eyes!, that is all.


Advertisement