Professional Web Applications Themes

How to display alternate text based on dynamic data? - Macromedia Dreamweaver

I need to display alternate text based on returns from a record set. For example, when my recordset returns "21," which is a code for an employee type, I want to display "Welder" rather than "21". When the return is "20" I want to display "steamfitter" rather than "20". Those two numbers are the only two codes I have to deal with, so the scope of the challenge is small. Unfortunately "welder" and "steamfitter" don't exist in the database, and I can't change it to include them....

  1. #1

    Default How to display alternate text based on dynamic data?

    I need to display alternate text based on returns from a record set.

    For example, when my recordset returns "21," which is a code for an employee type, I want to display "Welder" rather than "21". When the return is "20" I want to display "steamfitter" rather than "20".

    Those two numbers are the only two codes I have to deal with, so the scope of the challenge is small. Unfortunately "welder" and "steamfitter" don't exist in the database, and I can't change it to include them.



    stewboy webforumsuser@macromedia.com Guest

  2. #2

    Default Re:How to display alternate text based on dynamic data?

    Here's some code I'm trying but failing with. How close am I?

    <%
    If (SiteEmps.Fields.Item("EMP_CODE").Value = "20)" THEN
    <p align="center"><font color="#000000" size="+2" face="Arial, Helvetica, sans-serif">
    Steamfitters</font></p>)
    End If
    %>
    <%
    If (SiteEmps.Fields.Item("EMP_CODE").Value = "21)" THEN
    <p align="center"><font color="#000000" size="+2" face="Arial, Helvetica, sans-serif">
    Welders</font></p>)
    End If
    %>



    stewboy webforumsuser@macromedia.com Guest

  3. #3

    Default Re: Re:How to display alternate text based on dynamic data?

    your quotes are in the wrong place:

    Value = "20)"
    Value = "21)"

    should be:

    Value = "20")
    Value = "21")

    follow david's example - no need to duplicate that html.

    joe






    "stewboy" <webforumsusermacromedia.com> wrote in message
    news:bfov0p$pr3$1forums.macromedia.com...
    > Here's some code I'm trying but failing with. How close am I?
    >
    > <%
    > If (SiteEmps.Fields.Item("EMP_CODE").Value = "20)" THEN
    > <p align="center"><font color="#000000" size="+2" face="Arial, Helvetica,
    sans-serif">
    > Steamfitters</font></p>)
    > End If
    > %>
    > <%
    > If (SiteEmps.Fields.Item("EMP_CODE").Value = "21)" THEN
    > <p align="center"><font color="#000000" size="+2" face="Arial, Helvetica,
    sans-serif">
    > Welders</font></p>)
    > End If
    > %>
    >
    >
    >

    Joe {RoastHorse} Guest

  4. #4

    Default Re: How to display alternate text based on dynamic data?

    On Thu, 24 Jul 2003 10:40:33 -0500, "David R. Wheeler"
    <dont-wantno.spam> wrote:
    >myField = (rsName.Fields.Item("column").Value)
    >If myField = "20" Then
    > jobTitle = "steamfitter"
    >Else
    > jobTitle = "Welder"
    >End If
    Might be easier, or more intuitive, if you use a select case statement
    because you KNOW, as time goes on, there will be more codes:

    myField = SiteEmps.Fields.Item("EMP_CODE").Value
    Select Case myField
    Case "20" jobTitle = "steamfitter"
    Case "21" jobTitle = "welder"
    Case Else jobTitle = "unknown"
    End Select

    Now, if you get another, it's quick and easy to add it.

    All that said, you should think about the future when, one day, you'll
    decide to place the job titles in a table.


    Gary
    Gary White Guest

  5. #5

    Default Re: How to display alternate text based on dynamic data?

    > Might be easier, or more intuitive, if you use a select case statement
    because you KNOW, as time goes on, there will be more codes:

    Very true, but I'm only on my 2nd pot of coffee and not quite thinking ahead yet! :)

    --

    Dave
    -----------------------------------------------------------------
    If I were half as smart as people think I am...
    I'd be twice as smart as I was before I forgot everything.
    (Official victim of CRAFT Syndrome)

    =======================


    David R. Wheeler Guest

  6. #6

    Default Re: How to display alternate text based on dynamic data?

    >>
    >>"stewboy" <webforumsusermacromedia.com> wrote in message
    >>news:bfov0p$pr3$1forums.macromedia.com...
    >>> Here's some code I'm trying but failing with. How close am I?
    >>>
    >>> <%
    >>> If (SiteEmps.Fields.Item("EMP_CODE").Value = "20)" THEN
    >>> <p align="center"><font color="#000000" size="+2" face="Arial, Helvetica,
    >>sans-serif">
    >>> Steamfitters</font></p>)
    >>> End If
    >>> %>
    >>> <%
    >>> If (SiteEmps.Fields.Item("EMP_CODE").Value = "21)" THEN
    >>> <p align="center"><font color="#000000" size="+2" face="Arial, Helvetica,
    >>sans-serif">
    >>> Welders</font></p>)
    >>> End If
    >>> %>
    >>>
    >>>
    >>>
    >>
    Try this

    <%
    if (CInt(SiteEmps.Fields.Item("EMP_CODE").Value) = 20) then
    %>
    <p style="text-align:center; color:#000000; font-size:14pt;
    font-family:Arial, Helvetica,sans-serif">Steamfitters</p>

    <% else if (CInt(SiteEmps.Fields.Item("EMP_CODE").Value) = 21) then
    %>
    <p style="text-align:center; color:#000000; font-size:14pt;
    font-family:Arial, Helvetica,sans-serif">Welders</p>
    <%
    end if
    %>

    I have corrected the html, because the font tag is deprecated and
    should not be used. I have put inline style in for you, though it
    would in fact be better in an external stylesheet.

    Note the use of the CInt function to make sure that the read field is
    interpreted as a number, which can be compared with the numbers you
    require.


    Paul Taylor
    Paul Taylor Guest

Similar Threads

  1. Dynamic control creation in datagrid based on data in that column
    By mitramay@gmail.com in forum ASP.NET Building Controls
    Replies: 1
    Last Post: September 24th, 05:51 AM
  2. Asp.net2 Menu control dynamic display based on User Role!!!Help please!!!
    By Sri Reddy in forum ASP.NET Building Controls
    Replies: 3
    Last Post: June 21st, 05:09 PM
  3. how to display dynamic data in groups
    By Rob in forum Macromedia Dynamic HTML
    Replies: 0
    Last Post: December 25th, 09:25 PM
  4. Replies: 1
    Last Post: September 16th, 05:00 AM
  5. Dynamic List based on form field data
    By Brian S. Kiesel in forum Macromedia Dreamweaver
    Replies: 1
    Last Post: July 14th, 05:02 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139