Variables in HTML

Discussion in 'HTML' started by Allen Flick, Jan 7, 2004.

  1. Allen Flick

    Allen Flick Guest

    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
     
    Allen Flick, Jan 7, 2004
    #1
    1. Advertising

  2. Allen Flick

    Mark Parnell Guest

    On Wed, 07 Jan 2004 22:14:56 GMT, Allen Flick declared in alt.html:
    >
    > 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

    --
    Mark Parnell
    http://www.clarkecomputers.com.au
     
    Mark Parnell, Jan 7, 2004
    #2
    1. Advertising

  3. Allen Flick

    Guest Guest

    "Allen Flick" <> wrote in message
    news:...
    > 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>
     
    Guest, Jan 7, 2004
    #3
  4. Mark Parnell wrote:
    > 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.
     
    Leif K-Brooks, Jan 8, 2004
    #4
  5. Allen Flick

    Mark Parnell Guest

    On Thu, 08 Jan 2004 00:05:53 GMT, Leif K-Brooks declared in alt.html:

    > Mark Parnell wrote:
    >> 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.


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

    --
    Mark Parnell
    http://www.clarkecomputers.com.au
     
    Mark Parnell, Jan 8, 2004
    #5
  6. Allen Flick

    Cameron Guest

    xyzzy wrote:

    <snip>
    > 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
     
    Cameron, Jan 8, 2004
    #6
  7. On Thu, 08 Jan 2004 00:05:53 +0000, Leif K-Brooks wrote:

    > Mark Parnell wrote:
    >> 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.


    Reply-To is not Followup-To, as I recall.

    --
    Some say the Wired doesn't have political borders like the real world,
    but there are far too many nonsense-spouting anarchists or idiots who
    think that pranks are a revolution.
     
    Owen Jacobson, Jan 8, 2004
    #7
  8. Allen Flick wrote:

    > 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.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me - http://www.goddamn.co.uk/tobyink/?page=132
     
    Toby A Inkster, Jan 8, 2004
    #8
  9. Allen Flick

    josuf107

    Joined:
    Jul 8, 2010
    Messages:
    1
    Back to the Future

    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.
     
    josuf107, Jul 8, 2010
    #9
  10. Allen Flick

    sim

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

    websummaries.blogspot.com/2010/12/pass-and-use-variables-in-aspnet-server.html
     
    sim, Dec 13, 2010
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. avnrao
    Replies:
    0
    Views:
    3,385
    avnrao
    May 7, 2004
  2. Replies:
    1
    Views:
    949
  3. dwok
    Replies:
    7
    Views:
    710
    Hal Rosser
    Mar 4, 2005
  4. Replies:
    9
    Views:
    985
  5. Adam Akhtar
    Replies:
    9
    Views:
    558
    Florian Gilcher
    Aug 16, 2008
Loading...

Share This Page