Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-2">
- <title>Pizza Page</title>
- <link rel="stylesheet" type="text/css" href="mainStyles.css" />
- <script type="text/javascript">
- function showForms(variable)
- {
- hideAll();
- switch(variable)
- {
- case "3":
- changeObjectVisibility("number3","visible");
- case "2":
- changeObjectVisibility("number2","visible");
- case "1":
- changeObjectVisibility("number1","visible");
- break;
- }
- }
- function switchDiv(div_id)
- {
- var style_sheet = getStyleObject(div_id);
- if (style_sheet)
- {
- hideAll();
- changeObjectVisibility(div_id,"visible");
- }
- else
- {
- alert("sorry, this only works in browsers that do Dynamic HTML");
- }
- }
- function hideAll()
- {
- changeObjectVisibility("number1","hidden");
- changeObjectVisibility("number2","hidden");
- changeObjectVisibility("number3","hidden");
- }
- function changeObjectVisibility(objectId, newVisibility)
- {
- // first get a reference to the cross-browser style object
- // and make sure the object exists
- var styleObject = getStyleObject(objectId);
- if(styleObject)
- {
- styleObject.visibility = newVisibility;
- return true;
- }
- else
- { // we couldn't find the object, so we can't change its visibility
- return false;
- }
- }
- function getStyleObject(objectId)
- {
- if(document.getElementById && document.getElementById(objectId))
- {
- return document.getElementById(objectId).style;
- }
- else if (document.all && document.all(objectId))
- {
- return document.all(objectId).style;
- }
- else if (document.layers && document.layers[objectId])
- {
- return document.layers[objectId];
- }
- else
- {
- return false;
- }
- }
- </script>
- </head>
- <body>
- <img alt="banner" src="banner2.png">
- <form id="input" action="">
- <label> Ile składników?</label>
- <SELECT NAME="mylist" onchange="showForms(this.value)">
- <OPTION VALUE="0">0</OPTION>
- <OPTION VALUE="1">1</OPTION>
- <OPTION VALUE="2">2</OPTION>
- <OPTION VALUE="3">3</OPTION>
- </SELECT>
- </form>
- <span id="txtHint"></span>
- <?php
- try
- {
- $user = 'pizzaMan';
- $pass = 'qwerty';
- $dbh = new PDO('mysql:host=localhost;dbname=jz', $user, $pass);
- $i = 0;
- foreach($dbh->query('SELECT * from dodatki') as $row)
- {
- $tabela[$i] = $row['nazwa'];
- $i = $i + 1;
- }
- $ileDodatkow = $i;
- $dbh = null;
- }
- catch (PDOException $e)
- {
- print "Error!: " . $e->getMessage() . "<br/>";
- die();
- }
- // trzeba teraz dynamicznie stworzyć formularze
- for ($i = 1; $i < 4; $i++)
- {
- $polecenie = '<div id="number';
- $polecenie .= $i;
- $polecenie .= '" style="visibility: hidden">';
- $polecenie .= '<form name="';
- $polecenie .= $i;
- $polecenie .= 'form" action=""><select>';
- $opcje = '';
- for ($j = 0; $j < $ileDodatkow; $j++)
- {
- $opcje .= '<option>';
- $opcje .= $tabela[$j];
- $opcje .= '</option>';
- }
- $polecenie .= $opcje;
- $polecenie .= '</select></form></div>';
- echo $polecenie;
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement