Text variables are fundamental building blocks of the WebDNA language. They are simple to understand and easy to weave into your code.
[text]variablename=value[/text][text]maincolor=#660000[/text]
[text]secondcolor=#eebb21[/text]
[text]thirdcolor=#f0e2b8[/text]
<style type="text/css"><!--
.mainhead { font-weight: bold; font-size: 25px ; color:[maincolor] }
.subhead { color: [secondcolor]; font-weight: bold; font-size: 13px }
.menubar { color:[thirdcolor]; background-color: [maincolor]; }
....plus the dozens more styles with colors involved.
--></style>
the name of a text variable is limited to 49 characters.
Parameters | Description |
---|---|
multi | (optional) "T" or "F". Allows you to assign more than one text variable in a single context. [text multi=T]var1=Joe&var2=Fred[/text] simultaneously assigns the two variables. (There is no need to use multi=f for single variables.) |
show | (optional) "T" or "F". Default behavior is to hide the value when assigning to a text variable (the opposite of a math variable). If you want the value to be shown at the same time it is assigned to a variable, you may set Show=T. But if you set multi=T at the same time, then no values will be displayed. (There is no reason to ever use show=f, as this is default behavior.) |
secure | (optional) "T" or "F". Default is "T". Setting secure=F makes the text variable overrideable by incoming form variables. This is not recommended, and the default behavior is secure. Sometimes you might want a form on the preceding page to override an embedded variable, and in this case, you'd use secure=f for the embedded text contect. However, this also makes it possible for a visitor to type in the name=value pair in the URL, which would override the embedded one. So use this with caution, only if no harm could result. |
WebDNA expects anything after the = to be part of the set variable. If the value also contains an =, this will not mess anything up, and in fact, it is not uncommon to set a variable consisting of a string such as db=somedb.db&eqsomefielddatarq=value&somefieldsort=1, to be used in a search context later. Something like this would of course not work in a [text multi=t] situation.
<!--HAS_WEBDNA_TAGS-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<title>Variables</title>
<meta name="generator" content="BBEdit 7.0.1">
</head>
<body>
<b>Can a variable be named the same and have different values?</b><hr>
Here is a variable named <b>"myVar"</b> that is of the types
"math" and "text". (see at bottom for "form")<br><br>
<b>The Code:</b><br>
<pre>[input][raw]
<b>The Results</b><br>
[text]myVar=text[/text]
[math show=F]myVar=1[/math]
Which variable type takes precedence?<br>
Answer: [myVar]<br><br>
Methods to be sure to display specific types of variables:<br>
TextVar = [listvariables type=text&name=myVar][value][/listvariables]<br>
MathVar = [listvariables type=math&name=myVar][value][/listvariables]<br>
[hideif [url][formvariables name=myVar][value][/formvariables][/url]=]
FormVar = [formvariables name=myVar][value][/formvariables]<br>
[/hideif]
<br>
TextVar = [myVar]<br>
MathVar = [math]myVar[/math]<br><br>
What about Form Variables?<br>
Formvariables work in the same way. Try appending to this URL
"?myVar=FormVar" and see what you get.
[/raw][/input]</pre>
<hr>
<b>The Results</b><br>
[text]myVar=text[/text]
[math show=F]myVar=1[/math]
Which variable type takes precedence?<br>
Answer: [myVar]<br><br>
Methods to be sure to display specific types of variables:<br>
TextVar = [listvariables type=text&name=myVar][value][/listvariables]<br>
MathVar = [listvariables type=math&name=myVar][value][/listvariables]<br>
[hideif [url][formvariables name=myVar][value][/formvariables][/url]=]
FormVar = [formvariables name=myVar][value][/formvariables]<br>
[/hideif]
<br>
TextVar = [myVar]<br>
MathVar = [math]myVar[/math]<br><br>
What about Form Variables?<br>
Formvariables work in the same way. Try appending to this URL
"?myVar=FormVar" and see what you get.
<hr>
</body>
</html>
There are a few 'reserved' scope names:
"global" - refers to the 'normal/secure' template variable space.
"local" - When used inside of a function or scope context, refers to the variable space associated with the current function or scope.
"insecure" - Refers to the 'insecure' template variable space (this space also includes HTML form variables).
DOWNLOAD WEBDNA NOW!
WebDNA applications...
WebDNA LibrariesA list of available libraries for WebDNA...
[biotype]BioType is a behavioral biometrics WebDNA function based on ADGS research and development (from version 8...
F.A.QA compilation of some user's questions...
Technical Change HistoryThis Technical Change History provides a reverse chronological list of WebDNA changes...
WebDNA ModulesA list of the currently available modules...
Removes HTML or WebDNA tags from a string of text...
[listfiles]When listing files...
[formvariables]Lists all the form variables and parameters passed to the current page...
[getchars]Extracts a portion of the text (also known as substring or Mid$)...
[!]Hides text...
DB encryptionDatabase Automatic Encryption (from WebDNA 8...