How to display alternate text based on dynamic data?

Ask a Question related to Macromedia Dreamweaver, Design and Development.

  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. Similar Questions and Discussions

    1. Dynamic control creation in datagrid based on data in that column
      I am creating a dynamic datagrid. The controls in some of the template columns will have to be generated based on the data contained in them (i.e....
    2. Asp.net2 Menu control dynamic display based on User Role!!!Help please!!!
      Hi I want to create a horizontal menu on my website being built using asp.net2 with menu items based on the "role" of the user who logged into the...
    3. how to display dynamic data in groups
      Hello, I'm trying to create a 3 column table with grouping. In the database, I have a table where I'm extracting two fields Index, and Name. The...
    4. display text field based on the selection choices
      I want to display credit card fields when the user selects the option paid membership. If user selects the option free membership, then the credit...
    5. Dynamic List based on form field data
      --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.500 / Virus Database: 298 -...
  3. #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

  4. #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" <webforumsuser@macromedia.com> wrote in message
    news:bfov0p$pr3$1@forums.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

  5. #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-want@no.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

  6. #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

  7. #6

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

    >>
    >>"stewboy" <webforumsuser@macromedia.com> wrote in message
    >>news:bfov0p$pr3$1@forums.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

Posting Permissions

  • You may not post new threads
  • You may 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