Variables in HTML

A

Allen Flick

Forgive me if this sounds trivial, but I hack a lot, but I think
I would best be described as a "hack of all languages". What
that means is I know just enough to be dangerous in the
computer languages I mess with.

Anyway........... I have a little applet I found online somewhere
and it has to do with displaying images. Now, the path to the
selected images is lengthy, so I've been looking around in what
I have for info on variable use and surprising to me I can't get
any useful info where I've looked. So, I thought I'd come here

What I want is a way to something like the following Tcl code:

set myPath "to/he/ong/path/to/my/photos"
set image01 "$myPath/image01.jpg"

and to follow with a lengthy list of imageXX.jpg's instead of having
to put in the long path in each line.

Not a major deal, but if it can be done, email me at my address
'cause I don't monitor newsgroups all the time.

Thanks for all help ........... ALF
 
M

Mark Parnell

What I want is a way to something like the following Tcl code:

set myPath "to/he/ong/path/to/my/photos"
set image01 "$myPath/image01.jpg"

and to follow with a lengthy list of imageXX.jpg's instead of having
to put in the long path in each line.

HTML is a markup language, not a programming language. It cannot do any
calculations, does not have variables, etc.

You would need some sort of server-side language (the above looks
similar to PHP), or possibly a pre-processor.
Not a major deal, but if it can be done, email me at my address
'cause I don't monitor newsgroups all the time.

Sorry, ask here, get answers here.

Why you shouldn't ask for E-mail responses on Usenet:
http://www.cs.tut.fi/~jkorpela/usenet/mail-responses
 
G

Guest

Allen Flick said:
Forgive me if this sounds trivial, but I hack a lot, but I think
I would best be described as a "hack of all languages". What
that means is I know just enough to be dangerous in the
computer languages I mess with.

Anyway........... I have a little applet I found online somewhere
and it has to do with displaying images. Now, the path to the
selected images is lengthy, so I've been looking around in what
I have for info on variable use and surprising to me I can't get
any useful info where I've looked. So, I thought I'd come here

What I want is a way to something like the following Tcl code:

set myPath "to/he/ong/path/to/my/photos"
set image01 "$myPath/image01.jpg"

and to follow with a lengthy list of imageXX.jpg's instead of having
to put in the long path in each line.

Not a major deal, but if it can be done, email me at my address
'cause I don't monitor newsgroups all the time.

Thanks for all help ........... ALF

You would be better off incorporating PHP or ASP or something serverside.
But, if you are hell-bent on using HTML only, you could use server side
includes (SSI).
I dont think you save much code though...

<html>
<body>
<h1>SSI Test</h1>
<!--#set var="dir" value="/~myhomedir/stuff/images/" -->
<img src='<!--#echo var="dir" -->stuff.jpg'>
</body>
</html>
 
L

Leif K-Brooks

Mark said:
Why you shouldn't ask for E-mail responses on Usenet:

Might carry a little more weight if you weren't setting a reply-to
header to your email address.
 
M

Mark Parnell

Might carry a little more weight if you weren't setting a reply-to
header to your email address.

I hadn't particularly realised I was. Thanks. Better?
 
C

Cameron

xyzzy wrote:

You would be better off incorporating PHP or ASP or something serverside.
But, if you are hell-bent on using HTML only, you could use server side
includes (SSI).
I dont think you save much code though...

<html>
<body>
<h1>SSI Test</h1>
<!--#set var="dir" value="/~myhomedir/stuff/images/" -->
<img src='<!--#echo var="dir" -->stuff.jpg'>
</body>
</html>

I don't know much about SSI, but...since when were they part of HTML?

~Cameron
 
T

Toby A Inkster

Allen said:
What I want is a way to something like the following Tcl code:

set myPath "to/he/ong/path/to/my/photos"
set image01 "$myPath/image01.jpg"

and to follow with a lengthy list of imageXX.jpg's instead of having
to put in the long path in each line.

I think the closest solution in HTML would be the BASE element:
http://www.w3.org/TR/html401/struct/links.html#edef-BASE

But if you want to use variables properly, then use a proper programming
language (such as Perl, PHP, C++, TCL, whatever) to output your HTML.
 
Joined
Jul 8, 2010
Messages
1
Reaction score
0
Back to the Future

Allen Flick said:
Forgive me if this sounds trivial, but I hack a lot, but I think
I would best be described as a "hack of all languages". What
that means is I know just enough to be dangerous in the
computer languages I mess with.

Anyway........... I have a little applet I found online somewhere
and it has to do with displaying images. Now, the path to the
selected images is lengthy, so I've been looking around in what
I have for info on variable use and surprising to me I can't get
any useful info where I've looked. So, I thought I'd come here

What I want is a way to something like the following Tcl code:

set myPath "to/he/ong/path/to/my/photos"
set image01 "$myPath/image01.jpg"

and to follow with a lengthy list of imageXX.jpg's instead of having
to put in the long path in each line.

Not a major deal, but if it can be done, email me at my address
'cause I don't monitor newsgroups all the time.

Thanks for all help ........... ALF

I know this thread is old, old, old, but it's still the first hit on Google for the query "HTML variables". My guess is that a lot of people probably wish that HTML supported variables or macros, but it does not. That said, there are a lot of ways to achieve a measure of efficiency. In the case of an applet, you can use javascript to interact with the applet. You can place a script right into your HTML with the <script> tag and check out the syntax at the Sun Applet Tutorial.

If you don't know or don't want to know the Applet's object interface and you need to use the <param> tag, you can also do that with a little bit of inline javascript modifying the innerHTML attribute of the Applet element. If you have a lot of stuff you should avoid doing that since the script is executed when the browser loads the page, and therefore could slow things down. There may even be an issue with getting everything written before the user tries to work the applet.

Obviously PHP or ASP are good choices. That's probably what I would recommend to someone else. Go get educated at PHP or w3 schools.

Personally, I use the gcc preprocessor on my mac, or the lcc preprocessor on my pc. There are preprocessors better suited to HTML, but I missed C and even though sometimes the workarounds are dicey, it can definitely work. If you want to create sites with HTML and don't want to use server-side scripting or your server doesn't support scripting [lame] you should use a preprocessor. Google "HTML preprocessor" for some ideas.
 

sim

Joined
Dec 13, 2010
Messages
1
Reaction score
0
An ASP.net solution for this is mentioned in detail here.

websummaries.blogspot.com/2010/12/pass-and-use-variables-in-aspnet-server.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top