Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Dynamic IF Statement?!?!?HELP

  • 13-06-2011 9: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 Posts: 2,013 ✭✭✭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,065 ✭✭✭✭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,065 ✭✭✭✭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.


  • Registered Users, Registered Users 2 Posts: 5,246 ✭✭✭conor.hogan.2


    My eyes!, that is all.


Advertisement