Advertisement
Guest User

Untitled

a guest
May 21st, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 4.53 KB | None | 0 0
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3.     <head>
  4.         <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-2">
  5.         <title>Pizza Page</title>
  6.         <link rel="stylesheet" type="text/css" href="mainStyles.css" />
  7.         <script type="text/javascript">
  8.             function showForms(variable)
  9.             {
  10.                 hideAll();
  11.                 switch(variable)
  12.                 {
  13.                   case "3":
  14.                     changeObjectVisibility("number3","visible");
  15.                   case "2":
  16.                      changeObjectVisibility("number2","visible");
  17.                   case "1":
  18.                     changeObjectVisibility("number1","visible");
  19.                     break;
  20.                 }
  21.             }
  22.  
  23.             function switchDiv(div_id)
  24.             {
  25.                 var style_sheet = getStyleObject(div_id);
  26.                 if (style_sheet)
  27.                 {
  28.                     hideAll();
  29.                     changeObjectVisibility(div_id,"visible");
  30.                 }
  31.                 else
  32.                 {
  33.                     alert("sorry, this only works in browsers that do Dynamic HTML");
  34.                 }
  35.             }
  36.             function hideAll()
  37.             {
  38.                changeObjectVisibility("number1","hidden");
  39.                changeObjectVisibility("number2","hidden");
  40.                changeObjectVisibility("number3","hidden");
  41.             }
  42.             function changeObjectVisibility(objectId, newVisibility)
  43.             {
  44.                 // first get a reference to the cross-browser style object
  45.                 // and make sure the object exists
  46.                 var styleObject = getStyleObject(objectId);
  47.                 if(styleObject)
  48.                 {
  49.                     styleObject.visibility = newVisibility;
  50.                     return true;
  51.                 }
  52.                 else
  53.                 {  // we couldn't find the object, so we can't change its visibility
  54.                     return false;
  55.                 }
  56.             }
  57.  
  58.             function getStyleObject(objectId)
  59.             {
  60.                 if(document.getElementById && document.getElementById(objectId))
  61.                {
  62.                    return document.getElementById(objectId).style;
  63.                 }
  64.                 else if (document.all && document.all(objectId))
  65.                {
  66.                    return document.all(objectId).style;
  67.                 }
  68.                 else if (document.layers && document.layers[objectId])
  69.                {
  70.                    return document.layers[objectId];
  71.                 }
  72.                 else
  73.                 {
  74.                     return false;
  75.                 }
  76.             }
  77.     </script>
  78.     </head>
  79.     <body>
  80.         <img alt="banner" src="banner2.png">
  81.         <form id="input" action="">
  82.             <label> Ile składników?</label>
  83.             <SELECT NAME="mylist" onchange="showForms(this.value)">
  84.                 <OPTION VALUE="0">0</OPTION>
  85.                 <OPTION VALUE="1">1</OPTION>
  86.                 <OPTION VALUE="2">2</OPTION>
  87.                 <OPTION VALUE="3">3</OPTION>
  88.             </SELECT>
  89.         </form>
  90.         <span id="txtHint"></span>
  91.        
  92.         <?php
  93.        try
  94.        {
  95.            $user = 'pizzaMan';
  96.            $pass = 'qwerty';
  97.            $dbh = new PDO('mysql:host=localhost;dbname=jz', $user, $pass);
  98.            $i = 0;
  99.            foreach($dbh->query('SELECT * from dodatki') as $row)
  100.             {
  101.                 $tabela[$i] = $row['nazwa'];
  102.                 $i = $i + 1;
  103.             }
  104.             $ileDodatkow = $i;
  105.             $dbh = null;
  106.         }
  107.         catch (PDOException $e)
  108.         {
  109.             print "Error!: " . $e->getMessage() . "<br/>";
  110.             die();
  111.         }
  112.  
  113.         // trzeba teraz dynamicznie stworzyć formularze
  114.         for ($i = 1; $i < 4; $i++)
  115.        {  
  116.            $polecenie = '<div id="number';
  117.            $polecenie .= $i;
  118.            $polecenie .= '" style="visibility: hidden">';
  119.             $polecenie .= '<form name="';
  120.            $polecenie .= $i;
  121.            $polecenie .= 'form" action=""><select>';
  122.             $opcje = '';
  123.             for ($j = 0; $j < $ileDodatkow; $j++)
  124.            {
  125.              $opcje .= '<option>';
  126.               $opcje .= $tabela[$j];
  127.               $opcje .= '</option>';
  128.             }
  129.             $polecenie .= $opcje;
  130.             $polecenie .= '</select></form></div>';
  131.             echo $polecenie;
  132.         }
  133.         ?>
  134.     </body>
  135. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement