ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Write out html line

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Write out html line

    I am using CGI.

    I have a situation where user would like text in red under $ conditions.

    I have not written much js other than pilfering.

    I would think I need to put the conditional HTML into a variable. But then how do I execute the created variable?
    <script>
    var ac = /%availcr%/;
    if ac > 0 {
    <tr><td><strong>Available Credit:</strong> /%availcr%/ </td></tr>
    }
    else {
    <tr><td><font color="red"><strong>Available Credit:</strong> /%availcr%/ </td></tr>
    }
    </script>

    Any ideas would be appreciated.

  • #2
    Re: Write out html line

    Been a while since I did any CGIDEV2 (and I miss it!)...

    If I understand the requirement correctly my approach would be to define two sections in your HTML Template (with exactly the 2 different rows you have in your question)

    It is your RPG that then decides which section to write out, and there is no need for javascript at all ?

    Andrew

    Comment


    • #3
      Re: Write out html line

      No need for JS try this in your template and let the program fill in the color variable:


      Code:
      <tr><td style="color:/%availcrcolor%/"><strong>Available Credit:</strong> /%availcr%/ </td></tr>

      Comment


      • #4
        Re: Write out html line

        Originally posted by Andrew K View Post
        Been a while since I did any CGIDEV2 (and I miss it!)...

        If I understand the requirement correctly my approach would be to define two sections in your HTML Template (with exactly the 2 different rows you have in your question)

        It is your RPG that then decides which section to write out, and there is no need for javascript at all ?

        Andrew

        I tried that and it threw off the page and I could not seem to figure out why.

        I may go back to this option and work through it.

        Comment


        • #5
          Re: Write out html line

          Originally posted by Henrik Rutzou View Post
          No need for JS try this in your template and let the program fill in the color variable:


          Code:
          <tr><td style="color:/%availcrcolor%/"><strong>Available Credit:</strong> /%availcr%/ </td></tr>
          Awesome. That worked. Thank you

          Comment

          Working...
          X