[showif Comparison]Show This HTML[/showif]
Displays HTML conditionally only if the comparison is true.showif works correctly when it hides its container: any contexts inside the [showif] container (e.g. [append] or [replace] or [delete]) will NOT be executed if showif evaluates to false.
[showif [username]=Grant]You're allowed in![/showif]
Comparisons are always case-insensitive so "grant" equals "GRANT".
Comparison | Example | |
---|---|---|
equal | = | [showif [username]=SAGEHEN]Welcome Mr. Sagehen[/showif] |
not equal | ! | [showif [random]!45]...[/showif] |
contains | ^ | [showif [browsername]^Mozilla]...[/showif] |
begins with | ~ | [showif [ipaddress]~245.078.013]...[/showif]. Notice the IP address has been typed with 3 digits in each portion of the address. This is very important for making these comparisons work as expected. |
less than | < | [showif [random]<50]...[/showif] |
greater than | > | [showif [lastrandom]>25]...[/showif] |
divisible by | \ | [ShowIf [index]\3]...[/ShowIf] |
if both side of the equation are numbers, then the comparison for greater than, less than, and equals is performed numerically. If either side is not a number, then the comparison is performed alphabetically.
[showif I'm Friendly! Are you?=[question]]...[/showif ]
[showif [url]I'm Friendly! Are you?[/url]=[url][question][/url]]...[/showif]
[showif [browsername]^Macintosh]
Welcome Macintosh User!
[/showif]
[founditems]
<tr class=rowcolor[showif [index]\2]alt[/showif]><td>[name]</td><td>[email]</td></tr>
[/founditems]
[showif [formsubmitted]=t]
(WebDNA code to process the form)
<b>Thank you for contacting us!</b>
[/showif]
[hideif [formsubmitted]=t]
Please use this form to contact us.
<form method=post action="[thisurl]">
(Contact form here, including the following tag)
<input type=hidden name=formsubmitted value=t>
</form>
[/hideif]
A really useful way of blanking out the value of a text variable if it wasn't set (for whatever the reason) is shown in the example below. You HAVE to [url] your showif comparisons for ANY user enterable text to prevent user entered ampersands (&) and exclamation points (!) from improperly influencing the result.
This hint applies to the [hideif] context as well.
[showif [url][_email][/url]=[_email]][text]_email=[/text][/showif]
DOWNLOAD WEBDNA NOW!
A list of all WebDNA instructions...
WebDNA LibrariesA list of available libraries for WebDNA...
Download WebDNA ApplicationsWebDNA applications...
WebDNA ModulesA list of the currently available modules...
F.A.QA compilation of some user's questions...
Tips and TricksA list of user-submitted tips ...
Changes all lower case letters to upper case...
[thisurl][thisurl] displays the URL of the current page...
[encrypt][encrypt] and [decrypt] allow you to store sensitive data in your databases without risk of exposing it to prying eyes...
[cookie]Cookies are a great way to remember visitors...
[username]Using [password] and [username] is an easy was to show the browser login dialog box...
[listfiles]When listing files...