dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: Add a paragraph CONDITIONALLY

  1. #1
    Join Date
    Jun 2012
    Posts
    1

    Add a paragraph CONDITIONALLY

    I am attemting to modify an existing website whose maintenance I've inherited. I'm in the process of adding an "Alert" message to provide a way of warning our system users of any issues that may effect the turn-around time of their sample measurements.

    I've used Javascript to call a .txt file and display its contents in a paragraph formatted with a red background behind bold white font (like a weather alert on the Weather Channel). It works great. Only problem is, I do not want to display ANYTHING if there is no text to display, so I need to "CONDITIONALLY" display the red paragraph ONLY if there is something to display. I have the following two lines of code that display the message, but I cannot figure out how to make it conditional.

    <p align="center" style="background :red;" class="style1"><span style="color:white;font-weight:bold">ATTENTION: <br>

    <script language="javascript" type="text/javascript" src="file://anchovy/cs&s$/CMP%20Website%20Files/rednotice.txt"></script></span></p>

    In the rednotice.txt file, I have a single line of code that anyone in our department will be ble to access and edit whenever necessary, eliminating the need for everyone to learn HTML. An example of that txt file is below

    document.write('Please be advised that the CMP LIMS measurement system is temporarily unavailable. We will provide further updates when we feel like it.')

    I want to look at that file, and if the string inside the parenthesis is empty, just don't even display the paragraph. Otherwise, I'd end up with a big red bar that says "Attention" when there is nothing else to say.

  2. #2
    Join Date
    Jan 2011
    Location
    United Kingdom, London
    Posts
    117
    If you want to keep it they way you did it then the simplest solution would be to write that whole tag from javascript.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles