Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional text formatting?

Status
Not open for further replies.

T3leTech

Technical User
May 23, 2003
43
0
0
US
I am trying to find out if there is a way to do two things: make text in an HTML page visible or not (depending on db values) and also if the text is visible, how to make it "blink".

Here's the background: From a database, there is a field that can be one of three values (R, S or N). If the value in the field is "R" or "S", then I need a function to make text visible on the page, and also make the text blink. If the value is "N", then nothing should appear on the page (blank line or space is fine).

Thanks for any suggestions.

--Telephony Tech
 
Blinking text is one of the most obnoxious things to viewers, next to unwanted popups. There are also some health concerns with people with certain kinds of epilepsy, I've read, where blinking lights can bring on a seizure. I personally hate blinking stuff on a page, too, distracts me from what I went there to look at. I used to use blinking text in programming, but had so many complaints that I quit.

Lee
 
Thanks for the tip. Believe it or not, users have asked for this functionality.

If you can't recommend the blinking portion, do you have any recommendations to make the text appear or not, depending on the database value?

--Telephony Tech
 
for appearing:
<%
if val<>"N" then
response.write "Text can appear"
end if
%>

for blinking u have to place that text in a div, use the timer function and change the div's visiblity every X seconds...

Known is handfull, Unknown is worldfull
 
Thanks for the response vbkris,

However, I'm not sure I know where to put the code. Should the <% ... %> section be in the common.js file, or on the HTML page? If in the common.js file, how do I "call" it from the HTML page?

--Telephony Tech
 
>>From a database,

<%%> is ASP - Active Server Pages, u have to use server side programming, u cannot access a database from the server using javascript...

Known is handfull, Unknown is worldfull
 
Making text blink:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "[URL unfurl="true"]http://www.w3.org/TR/html4/strict.dtd">[/URL]

<html>
<head>
<title>new document</title>

<script language="javascript" type="text/javascript">
<!--

function changeDisplay() {
    var s = document.getElementById('blinky');
	s.style.display = s.style.display == '' ? 'none' : '';
	setTimeout('changeDisplay()', 500);
}

-->
</script>

<style type="text/css">

#blinky {
    display: '';
}

</style>

</head>

<body onload="setTimeout('changeDisplay()', 500);">

<span id="blinky">Blinking Text</span>

</body>

</html>


*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
As for your database value question, it's kind of hard to answer without knowing what scripting language you're using.

If you're using PHP, the following could work:
Code:
<?
if ($the_val == 'R' || $the_val == 'S') {
    echo '<span id="noblink">Text text text</span>';
} else {
    echo '<span id="blinky">Text text text</span>';
}
?>

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top