Results 1 to 4 of 4

Thread: [RESOLVED] Defining a Constant or Variable

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166

    Resolved [RESOLVED] Defining a Constant or Variable

    Is it possible to define a constant or variable at the front end of html
    that can be used throughout the rest of the program?

    Is so how (to define) and where would it go (be placed)?

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Defining a Constant or Variable

    HTML is not a programming language (thus you cannot consider it a "program") -- it's a mark-up language. you can't have variables in HTML. you would need to accomplish this in JavaScript (assuming you really want to use the front end/client to define the variable), in which case a variable is defined with the var keyword:
    Code:
    <script language="javascript">
      var myVar = 5;
    </script>

  3. #3
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: Defining a Constant or Variable

    Or you would just use PHP (or another scripting language)...
    Code:
    <?php
    $myVar = 5;
    ?>
    <p><?php echo $myVar;?></p>
    ...which results in HTML...
    Code:
    <p>5</p>

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166

    Re: Defining a Constant or Variable

    Thanks to both.

    Especially regarding reminder that HTML is "Mark Up Language".
    Tend to overlook this fact and expect more than it can deliver.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width