I purchased the Macromedia Studio MX 2004 suite a month ago, and have been
teaching HTML to myself. (I've previously programmed in ALGOL, FORTRAN, BASIC.
I've dabled around in C, C++, and PASCAL. I've been using LaTeX regularly for
ten years and consider myself well above average, approaching expert.) I've
learned quite a bit about HTML in one month, and have become quite comfortable
with it. I have a question that I haven't been able to find the answer to in
several sources.
I want to include the text "90 years" in eight different locations in my site.
Next year I'll need to change all occurrences of "90" to "91". Rather than
search and replace all of the "90" occurrences, can I define a command, say
"&age;", at the beginning of the document, set it's value to 90, and then
include the text "&age; years" in the eight locations? Next year, I'll only
have to change the one value of "&age;" to 91, and then this will be reflected
throughout all eight occurences in the document. If this is possible, how can
I use "&age;" in other documents within the same site? Can I include this
command definition in the css?
Thank you.
Kurt Todoroff
(e-mail address removed)
Markets, not mandates and mob rule.
Consent, not compulsion.
Wow. All these responses in this thread and no one really seemed to
answer your question!
The question is "Can HTML be used to make dynamic changes using variables,
loops, branching, or other techniques found in typical programming
languages?"
The answer is, "NO". Period. HTML is NOT A PROGRAMMING LANGUAGE!!!! (I am
yelling here only because I have seen people post, incorrectly, that it
is.)
But, of course, that is only in the most technical sense. There ARE ways
to do what you want to do.
Possibilities include...
1) Use a server-side scripting language. PHP, ASP, JSP, Perl,
AppleScript, C/C++, Ada, Ruby, etc. (I am getting a little carried away.
Stick to one of the first four).
2) Use Server-side Includes (SSI).
SSI is like a proto-programming language, although it is really pretty
much just focused on bringing other files into the scope of your current
HTML page. A Templating system, if you will.
In your case, I recommend finding out what capabilities you have available
to you on the server. Post back another question on the specifics on how
to do what you want when we know what you have to work with.
Example, using SSI:
"index.shtml"
<html>
<body>
I am <!--#include age.txt--> years old! Wow!
</body>
</html>
"age.txt"
90
(The exact syntax may be off by a character or space here or there, but it
is pretty darn close. I don't use SSI, I use PHP, so I am working from
memory here!)
later...