Forum Moderators: open

Message Too Old, No Replies

If a variable is not blank, render some text?

         

jfred1979

1:52 am on Jun 10, 2004 (gmt 0)

10+ Year Member



How do I have a document check to see if a string has a blank value, and if it's not render a link and some text? If the string is blank I don't want it to render anything. Thanks!

Rambo Tribble

2:34 am on Jun 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



if(char_string!=="")document.write('<a href="http://www.where_ever.com/">Where Ever</a>');

If you are adding to an existing page, you'll want to use innerHTML instead of document.write(), but that's another question.