Announcement

Collapse
No announcement yet.

HTML: global variables

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • HTML: global variables

    Is there a way to store color info (like rgb and hex) as global variables in html? I'm working on this website, and it's got maybe 10 or 20 thousand tables, most with the same bg color. The last thing I want to do is go through all of them and change the colors cause of one stupid mistake (and it's more convenient than global find/replace).
    cIV list: cheats
    Now watch this drive!

  • #2
    HTML doesn't have variables. Period.

    It's a markup language, not a programming language.

    What you probably want is a scripting environment of some kind (PHP could do that no problem), or CSS somehow.
    "The issue is there are still many people out there that use religion as a crutch for bigotry and hate. Like Ben."
    Ben Kenobi: "That means I'm doing something right. "

    Comment


    • #3
      For large sections, such as navbar and some text, I'm using php includes, but I was hoping there was an easier way to do it with something like css. (really wasn't clear above)
      cIV list: cheats
      Now watch this drive!

      Comment


      • #4
        If you're already using PHP, just use a PHP variable.

        Then use "$color" everywhere and define it once at the top.
        "The issue is there are still many people out there that use religion as a crutch for bigotry and hate. Like Ben."
        Ben Kenobi: "That means I'm doing something right. "

        Comment


        • #5
          You can do it with CSS. Suppose (for some reason) you want all cells in bright red. Either in the head of your document, or better, in a external css file, write:

          td {background-color: #ff0000}

          All table cells in linked documents wil then be red. You can override indivudual cells with by using the CLASS attribute to link another style or using an inline style:

          <td align="center" width="45" style="background-color: #ffff00">
          Christianity: The belief that a cosmic Jewish Zombie who was his own father can make you live forever if you symbolically eat his flesh and telepathically tell him you accept him as your master, so he can remove an evil force from your soul that is present in humanity because a rib-woman was convinced by a talking snake to eat from a magical tree...

          Comment


          • #6
            cIV list: cheats
            Now watch this drive!

            Comment


            • #7
              I think I'll go with the php approach
              I allready have a mile long css file, an all the tables are slightly different- don't want to go around with
              Code:
              td {blah: "" etc}
                   .{}
                   .{}
                   .{}
                   .{}
              and then have to redefine class for each table.

              Lets see how this works.
              cIV list: cheats
              Now watch this drive!

              Comment


              • #8
                You can do the same thing for any element, it doesn't have to just be TD.

                Ten to twenty thousand tables. Man, and I thought my work was hard.
                Christianity: The belief that a cosmic Jewish Zombie who was his own father can make you live forever if you symbolically eat his flesh and telepathically tell him you accept him as your master, so he can remove an evil force from your soul that is present in humanity because a rib-woman was convinced by a talking snake to eat from a magical tree...

                Comment


                • #9
                  I know some css... enough to define styles

                  Well, maybe it's not exactly 20,000, but who's counting?
                  cIV list: cheats
                  Now watch this drive!

                  Comment


                  • #10
                    CSS is bloody simple.


                    On the one hand, if you're more comfortable with PHP, go with it. On the other hand, you do need to keep in mind future developers. My current task is ripping out a bunch of brilliant JavaScript that no one here at the company can understand. It functions very well, but since we can't understand it (it's extremly complex and well over 1200 lines), we can't modify it. It's been around for three years, and none of the developers here was here when it was written.
                    Christianity: The belief that a cosmic Jewish Zombie who was his own father can make you live forever if you symbolically eat his flesh and telepathically tell him you accept him as your master, so he can remove an evil force from your soul that is present in humanity because a rib-woman was convinced by a talking snake to eat from a magical tree...

                    Comment


                    • #11
                      No, no... I do know CSS... And I don't know how I've lived without it. The o'reilley book is right behind me.
                      cIV list: cheats
                      Now watch this drive!

                      Comment


                      • #12
                        Mea culpa, read too quickly.
                        Christianity: The belief that a cosmic Jewish Zombie who was his own father can make you live forever if you symbolically eat his flesh and telepathically tell him you accept him as your master, so he can remove an evil force from your soul that is present in humanity because a rib-woman was convinced by a talking snake to eat from a magical tree...

                        Comment


                        • #13
                          Alternatively, you could create variables using JavaScript.

                          Just giving you options.
                          Christianity: The belief that a cosmic Jewish Zombie who was his own father can make you live forever if you symbolically eat his flesh and telepathically tell him you accept him as your master, so he can remove an evil force from your soul that is present in humanity because a rib-woman was convinced by a talking snake to eat from a magical tree...

                          Comment


                          • #14
                            1,200 lines of JavaScript is a challenge?
                            "The issue is there are still many people out there that use religion as a crutch for bigotry and hate. Like Ben."
                            Ben Kenobi: "That means I'm doing something right. "

                            Comment


                            • #15
                              Originally posted by Asher
                              1,200 lines of JavaScript is a challenge?
                              I said at least. We really don't know how long it was, because it was all wrapped up into one long line. 1200 was where I got to before I was told to drop it.

                              Go here: http://www.acuvue.com/

                              Those twelve hundred+ lines of code control the buttons in the left side navbar. A couple rollovers, and a flyout menu? I could (and will) do the same with about 50 lines of code.
                              Christianity: The belief that a cosmic Jewish Zombie who was his own father can make you live forever if you symbolically eat his flesh and telepathically tell him you accept him as your master, so he can remove an evil force from your soul that is present in humanity because a rib-woman was convinced by a talking snake to eat from a magical tree...

                              Comment

                              Working...
                              X