Advertisement
Phr0zen_Penguin

Variable Variable Names In JavaScript - Demonstrated

Aug 29th, 2014
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 2.24 KB | None | 0 0
  1. <!DOCTYPE html>
  2.  
  3. <!--------------------------------------------------------------------------------------------------
  4.  --------------------------------------------------------------------------------------------------
  5.  [variable_var_names.html]
  6.     How to declare (and manipulate) multiple variables, with variable names, as needed, with the
  7.     added plus of indexing (and accessing) them in a way that standard arrays can't.
  8.  
  9.         (c) Damion 'Phr0z3n.dev' Tapper, 2014.
  10.         Email: Phr0z3n.Dev@Gmail.com
  11.  --------------------------------------------------------------------------------------------------
  12.  --------------------------------------------------------------------------------------------------->
  13.  
  14. <html>
  15.     <head>
  16.  
  17.         <title>
  18.             Phr0z3n.Dev's Variable Variable Names
  19.         </title>
  20.  
  21.         <style type="text/CSS">
  22.             body{
  23.                 font-family: helvetica;
  24.                 font-size: 11pt;
  25.             }
  26.  
  27.             #mainDiv{
  28.                 width: 350px;
  29.                 margin-left: auto;
  30.                 margin-right: auto;
  31.             }
  32.             div div[id$="Div"]{
  33.                 height: 150px;
  34.                 border: 1px dotted rgb(0, 0, 64);
  35.                 padding: 4px;
  36.             }
  37.             #firstDiv{
  38.                 background-color: rgb(224, 255, 255);
  39.             }
  40.             #secondDiv{
  41.                 background-color: rgb(255, 224, 255);
  42.             }
  43.             #thirdDiv{
  44.                 background-color: rgb(255, 255, 224);
  45.             }
  46.         </style>
  47.  
  48.         <script type="text/JavaScript" src="variable_var_names.js"></script>
  49.  
  50.     </head>
  51.     <body>
  52.  
  53.             <div id="mainDiv">
  54.                 <!--FIRST DIV-->
  55.                 <div id="firstDiv">
  56.                     <p>This is the first div.</p>
  57.                     <p>Its contents can be cleared and restored using the button below.</p>
  58.                 </div>
  59.                 <button id="firstButton" OnClick="JavaScript: divClearRestore('first');">Clear</button><br /><br /><br />
  60.  
  61.                 <!--SECOND DIV-->
  62.                 <div id="secondDiv">
  63.                     <p>This is the second div.</p>
  64.                     <p>Its contents can be cleared and restored using the button below.</p>
  65.                 </div>
  66.                 <button id="secondButton" OnClick="JavaScript: divClearRestore('second');">Clear</button><br /><br /><br />
  67.  
  68.                 <!--THIRD DIV-->
  69.                 <div id="thirdDiv">
  70.                     <p>This is the third div.</p>
  71.                     <p>Its contents can be cleared and restored using the button below.</p>
  72.                 </div>
  73.                 <button id="thirdButton" OnClick="JavaScript: divClearRestore('third');">Clear</button>
  74.             </div>
  75.  
  76.     </body>
  77. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement