Jump to content

leso9903

Members
  • Posts

    23
  • Joined

  • Last visited

leso9903's Achievements

Newbie

Newbie (1/7)

1

Reputation

  1. Hello, I'm receiving this: "Strict Standards: Creating default object from empty value in /opt/lampp/htdocs/uppgift6/pizzeria.html on line 40" When I try to type out some attributes from an xml-document. As I've understood it I'm putting something in an empty variable(?) - how do I fix this. <?phpinclude_once("JSON.php");$json = new Services_JSON();$pizzeria = "pizzeria.xml";$writedir = "writehere";$pizzeria = $writedir."/pizzeria.xml";$sxe = simplexml_load_file($pizzeria);$result = array();foreach ($sxe->menu->pizza as $pizza->ingredient) { // $result[] = (string)$pizza->ingredient["units"]; $result[] = (string)$pizza->ingredient["id"];}echo $json->encode($result);?> XML <?xml version="1.0" encoding="utf-8"?><pizzeria> <menu> <pizza id="5"> <name>Al tonno</name> <description>A simple pie with Tunafish</description> <popularity>50</popularity> <ingredient id="1" units="2" /> <ingredient id="2" units="2" /> <ingredient id="4" units="4" /> <ingredient id="5" units="2" /> </pizza> <pizza id="1"> <name>Margherita</name> <description>The simple vegetarian choice</description> <popularity>99</popularity> <ingredient id="1" units="2" /> <ingredient id="2" units="3" /> </pizza> <pizza id="8"> <name>Cappriciosa</name> <description>A classic pizza with ham and mushrooms</description> <popularity>450</popularity> <ingredient id="1" units="1" /> <ingredient id="2" units="2" /> <ingredient id="17" units="3" /> <ingredient id="3" units="2" /> </pizza> <pizza id="2"> <name>Al funghi</name> <description>Prepared with fresh mushrooms</description> <popularity>143</popularity> <ingredient id="1" units="2" /> <ingredient id="2" units="2" /> <ingredient id="3" units="2" /> </pizza> <pizza id="3"> <name>Vesuvio</name> <description></description> <popularity>345</popularity> <ingredient id="1" units="2" /> <ingredient id="2" units="2" /> <ingredient id="17" units="3" /> </pizza> <pizza id="4"> <name>Calzone</name> <description>A very popular turnover Pizza.</description> <popularity>634</popularity> <ingredient id="1" units="2" /> <ingredient id="2" units="2" /> <ingredient id="17" units="3" /> </pizza> <pizza id="6"> <name>Opera</name> <description></description> <popularity></popularity> <ingredient id="1" units="2" /> <ingredient id="2" units="2" /> <ingredient id="4" units="3" /> </pizza> <pizza id="7"> <name>Orientale</name> <description></description> <popularity>345</popularity> <ingredient id="1" units="2" /> <ingredient id="2" units="2" /> <ingredient id="14" units="3" /> <ingredient id="5" units="2" /> </pizza> <pizza id="9"> <name>Campaniola</name> <description></description> <popularity></popularity> <ingredient id="1" units="2" /> <ingredient id="2" units="2" /> <ingredient id="10" units="1" /> <ingredient id="6" units="2" /> <ingredient id="5" units="2" /> </pizza> <pizza id="10"> <name>Pineapple</name> <description></description> <popularity>678</popularity> <ingredient id="1" units="2" /> <ingredient id="2" units="2" /> <ingredient id="7" units="2" /> <ingredient id="17" units="3" /> </pizza> <pizza id="11"> <name>Banana</name> <description></description> <popularity>230</popularity> <ingredient id="1" units="2" /> <ingredient id="2" units="2" /> <ingredient id="8" units="2" /> <ingredient id="17" units="2" /> </pizza> <pizza id="12"> <name>Sultan</name> <description></description> <popularity></popularity> <ingredient id="1" units="2" /> <ingredient id="2" units="2" /> <ingredient id="5" units="2" /> <ingredient id="14" units="3" /> <ingredient id="12" units="1" /> </pizza> <pizza id="13"> <name>Calamata</name> <description></description> <popularity>212</popularity> <ingredient id="1" units="2" /> <ingredient id="2" units="2" /> <ingredient id="4" units="2" /> <ingredient id="11" units="1" /> </pizza> <pizza id="14"> <name>Natali</name> <description></description> <popularity>33</popularity> <ingredient id="1" units="2" /> <ingredient id="2" units="2" /> <ingredient id="10" units="1" /> <ingredient id="3" units="1" /> <ingredient id="6" units="1" /> </pizza> <pizza id="15"> <name>Orientale special</name> <description></description> <popularity>90</popularity> <ingredient id="1" units="3" /> <ingredient id="2" units="2" /> <ingredient id="14" units="3" /> <ingredient id="18" units="1" /> <ingredient id="5" units="2" /> </pizza> <pizza id="16"> <name>Hawaii</name> <description></description> <popularity>247</popularity> <ingredient id="1" units="2" /> <ingredient id="2" units="2" /> <ingredient id="17" units="3" /> <ingredient id="8" units="1" /> <ingredient id="7" units="1" /> <ingredient id="9" units="1" /> </pizza> <pizza id="17"> <name>Bussola</name> <description></description> <popularity>340</popularity> <ingredient id="1" units="2" /> <ingredient id="2" units="2" /> <ingredient id="17" units="3" /> <ingredient id="11" units="2" /> </pizza> <pizza id="18"> <name>Du chef</name> <description></description> <popularity>560</popularity> <ingredient id="1" units="2" /> <ingredient id="2" units="2" /> <ingredient id="14" units="2" /> <ingredient id="3" units="2" /> <ingredient id="13" units="1" /> <ingredient id="5" units="2" /> </pizza> <pizza id="20"> <name>Romana</name> <description></description> <popularity>74</popularity> <ingredient id="1" units="2" /> <ingredient id="2" units="2" /> <ingredient id="11" units="3" /> <ingredient id="3" units="2" /> </pizza> <pizza id="21"> <name>La Bella</name> <description></description> <popularity>344</popularity> <ingredient id="1" units="2" /> <ingredient id="2" units="2" /> <ingredient id="10" units="3" /> <ingredient id="3" units="2" /> </pizza> <pizza id="31"> <name>Chicken Pizza</name> <description></description> <popularity>184</popularity> <ingredient id="1" units="2" /> <ingredient id="2" units="2" /> <ingredient id="19" units="2" /> <ingredient id="12" units="1" /> <ingredient id="9" units="2" /> <ingredient id="5" units="1" /> <ingredient id="15" units="1" /> </pizza> <pizza id="47"> <name>Texas</name> <description>American pan pizza</description> <popularity>281</popularity> <ingredient id="1" units="3" /> <ingredient id="2" units="4" /> <ingredient id="10" units="4" /> <ingredient id="16" units="3" /> <ingredient id="15" units="1" /> </pizza> <pizza id="48"> <name>Boston</name> <description>American pan pizza</description> <popularity>281</popularity> <ingredient id="1" units="3" /> <ingredient id="2" units="4" /> <ingredient id="4" units="3" /> <ingredient id="11" units="2" /> <ingredient id="16" units="1" /> </pizza> </menu> <storage> <ingredient id="1" name="Tomato Sauce" in_storage="256" /> <ingredient id="2" name="Cheese" in_storage="25" /> <ingredient id="3" name="Mushroom" in_storage="3" /> <ingredient id="4" name="Tunafish" in_storage="6" /> <ingredient id="5" name="Onions" in_storage="29" /> <ingredient id="6" name="Olives" in_storage="29" /> <ingredient id="7" name="Pineapple" in_storage="178" /> <ingredient id="8" name="Banana" in_storage="121" /> <ingredient id="9" name="Curry" in_storage="670" /> <ingredient id="10" name="Salami" in_storage="34" /> <ingredient id="11" name="Shrimps" in_storage="93" /> <ingredient id="12" name="Fresh Tomatos" in_storage="23" /> <ingredient id="13" name="Tabasco" in_storage="17" /> <ingredient id="14" name="Minced Meat" in_storage="123" /> <ingredient id="15" name="Paprika" in_storage="17" /> <ingredient id="16" name="Gorgonzola" in_storage="17" /> <ingredient id="17" name="Ham" in_storage="54" /> <ingredient id="18" name="Eggs" in_storage="180" /> <ingredient id="19" name="Chicken" in_storage="121" /> <ingredient id="20" name="Kebab" in_storage="151" /> </storage></pizzeria>
  2. I made it work with trial and error but the manuals doesn't make sense to me. Can I tell you how I think it works, then you correct me? the following code, for example: foreach ($sxe->menu->pizza as $pizza->ingredient) { $result[] = (string)$pizza->ingredient["units"];} foreach is a loop $sxe is my root - is it possible to skip one step, for example $sxe->pizza (I skipped $menu)? I know it works in some cases but why does it work? As for the 'as' part I've no clue. $result[] is telling the engine that it is an array and will keep going until every targeted node has been processed? string is remaking the data from xml to javascript-readable data. thanks a bunch!
  3. Hello, I've been trying to print out data from an array but I dont understand the code I'm working with.. A part of the xml file is seen down below. How do I only get the description or the name for example to be printed out in my html-file? In other words, my problem is that all the data gets printed out, I only want specific data. <?xml version="1.0" encoding="utf-8"?><pizzeria> <menu> <pizza id="5"> <name>Al tonno</name> <description>A simple pie with Tunafish</description> <popularity>50</popularity> <ingredient id="1" units="2" /> <ingredient id="2" units="2" /> <ingredient id="4" units="4" /> <ingredient id="5" units="2" /> </pizza> <!DOCTYPE html><html><head><meta charset="utf-8"><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script><link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"><script type="text/javascript" src="scripts.js"></script><link rel="stylesheet" href="style.css" /><?phpinclude_once("JSON.php");$json = new Services_JSON();//$pizzeria = "pizzeria.xml";$writedir = "writehere";$pizzeria = $writedir."/pizzeria.xml";$sxe = simplexml_load_file($pizzeria);$result = array();foreach ($sxe->Children() as $pizza) { $result[] = $pizza;}echo $json->encode($result);?></head><body><h1>PIZZERIA ZORBA</h1><ul><li>Start</li><li>Order</li><li>About</li><li>TOP10</li><li>Foodstock</li><li>Recipies</li></ul></body></html>
  4. Hello, first off I wanted to thank you guys for helping me this far. I've posted a couple of times here and I got my questions answered and my problems fixed. I hope I can return the favour when I'm abit more knowledgable. Anyway, I'm working on a registration form and I've implemented some animation effects such as the input field turning red on click when there is no data inserted. I'd like to know how to keep the red input field even after the page has loaded. I've noticed that the inserted data inside the input fields are still there after I've updated the page - I'd like the same for my input field color. I've heard that it has something to do with a global variable and some false/true statements. All of this is done i jquery and I'd like to keep doing it in jquery. Also, please comment on the theory in question if there is a solution to this problem. I've a much easier time to remember stuff when there is some info about it.. thanks in advance! /Len
  5. Hello, I'd like to know if it's possible to set several conditions for an else if statement. This I know I can do: if (X==" ") {blabla} else {} But I'd like several statements like so: if (X==" " and Y==5 and Z==6) {blabla } else {} How do I do that?
  6. Thanks. solved using $("#bla:bla").val(result.name);
  7. Hello, how do I put values inside an input box onclick? I've data from JSON. For example, if I want to put data inside a div element i just do: document.getElementById("#fullname").innerHTML=result.name; How do I do the corresponding to an input-box? It doesn't work if I just put the input-box's id. Should I put .value() somewhere? The name of the JSON array is result and the objects inside the array is named ssn, name, street etc. I want to click a button (later on I'll take the value from the input box itself), look up the data inside the JSON array and fill in rest of the registration forms. HTML <form name="form" action="" method="post"> <fieldset> <legend>Name and address</legend> SSN: <input type="text" id="SSN"/><br> <button type="button" onclick="lookUp()" id="knapp">Name and adress id</button> <br> Full name: <input onkeyup="" type="text" id="fullname" name="full"><br><br> Street and number: <input type="text"><br><br> Postal code: <input type="text"><br><br> City: <input type="text"><br> </fieldset> <fieldset> <legend>Username and password</legend> Username: <input type="text"><br><br> Password: <input type="text"><br><br> <input type="checkbox" name="show" value="X">Show password<br> </fieldset> </form> function lookUp(){ var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ document.myForm.time.value = ajaxRequest.responseText; } }$.getJSON( "ssn_lookup.php" , {ssn: "121212121212" }, function (result){ if (!result){ alert("not found"); } else { document.getElementById("myDiv").innerHTML=result.name; document.getElementById("#fullname").innerHTML=result.name; } }); }
  8. Thanks alot you guys for answering. Thing is, I'm doing this webprogramming course and the AJAX assignment is actually before the PHP tutorial..
  9. Hello I'm suppose to create a registration form that searches through a php-file and comments "entry not found" when the wrong social security is typed. I've no clue what I'm doing but atleast I got a apache server started... What should I type in my jscript file? The php-script that I'm suppose to use don't contain any data, I'm confused.. HTML <html> <head><script type="text/javascript" src="scripts.js"></script> </head> <body> <?php echo date('c'); ?> </p> <form name="form" action="" method="post"> <fieldset> <legend>Name and address</legend> <div id="myDiv"></div> SSN: <input type="text" id="SSN" onkeyup="lookUp()"/><br> <div id="underInput" /><br> Full name: <input onkeyup="showHint2(this.value)" type="text" id="fullname" name="full"><br> <div id="txtHint2"></div> Street and number: <input type="text"><br> Postal code: <input type="text"><br> City: <input type="text"> </fieldset> <fieldset> <legend>Username and password</legend> Username: <input type="text"><br> Password: <input type="text"><br> <input type="checkbox" name="show" value="X">Show password<br> </fieldset> </form><h3>Start typing a name in the input field below:</h3><form action=""> First name: <input type="text" id="txt1" onkeyup="showHint(this.value)" /></form><p>Suggestions: <span id="txtHint"></span></p> </body></html> JSCRIPT function lookUp(){ $.getJSON( "ssn_lookup.php" , //The URL to perform the lookup {ssn: "121212121212" }, //The data you send function (result){ //The function to fire upon return if (!result){ //result is JSON formatted (Execute if SSN does not exist) } else { (Execute if SSN exists) } });} Server PHP file <?php// FILE: ssn_lookup.php//// LAST MODIFIED: 2006-03-23//// AUTHOR: Troy Wolf <troy@troywolf.com>//// DESCRIPTION: Allow scripts to request content they otherwise may not be// able to. For example, AJAX (XmlHttpRequest) requests from a// client script are only allowed to make requests to the same// host that the script is served from. This is to prevent// "cross-domain" scripting. With proxy.php, the javascript// client can pass the requested URL in and get back the// response from the external server.//// USAGE: "proxy_url" required parameter. For example:// http://www.mydomain.com/proxy.php?proxy_url=http://www.yahoo.com//// proxy.php requires Troy's class_http. http://www.troywolf.com/articles// Alter the path according to your environment.require_once("class_http.php");/* $proxy_url = isset($_GET['proxy_url'])?$_GET['proxy_url']:false; if (!$proxy_url) { header("HTTP/1.0 400 Bad Request"); echo "proxy.php failed because proxy_url parameter is missing"; exit(); } */$proxy_url = "http://www.it.uu.se/edu/course/homepage/websiteconst/st13/assignments/4/scripts/ssn_lookup";// Instantiate the http object used to make the web requests.// More info about this object at www.troywolf.com/articlesif (!$h = new http()) { header("HTTP/1.0 501 Script Error"); echo "proxy.php failed trying to initialize the http object"; exit();}$h->url = $proxy_url;$h->postvars = $_REQUEST; //$_POSTif (!$h->fetch($h->url)) { header("HTTP/1.0 501 Script Error"); echo "proxy.php had an error attempting to query the url"; exit();}// Forward the headers to the client.$ary_headers = explode("n", $h->header);foreach ($ary_headers as $hdr) { header($hdr);}// Send the response body to the client.echo $h->body;?>
  10. Hi, I followed a tutorial on and I wrote exactly as he did but it still doesn't work. i also want to know where I can find a tutorial that you went through to create a registration form which includes social security number, name, adress and so on, as well as password visibility, username taken etc<!DOCTYPE><html><head> <script src="movies.js"></script></head><body onload="createList()"> Here are my favorite movies: <br/> <div id="divMovies"></div></body></html> JS function createList(){ var s; s = "<ul>" + <"li>Armageddon</li>" + <"li>fefwfe</li>" + <"li>wfewfew</li>" + "<ul>"; divMovies = document.getElementById("divMovies"); divMovies.innerHTML = s;} I'm very confused! thanks in advance.
  11. It works! thank you very very much. I've a followup question. say I want to have an animation that changes the opacity from 0 to 1 and vice versa. How would I go about doing that? I've changed the code a bit but it's basically what I got from you.. function mainmenu(){$(" #nav ul ").css({display: "none"}); // Opera Fix$(" #nav li").hover(function(){ $(this).children('ul').stop(true,true).slideDown("linear"); },function(){ $(this).children('ul').stop(true,true).slideUp("linear"); });} $(document).ready(function(){ mainmenu(); }) I changed slideUp/slideDown to opacity 1/0: function mainmenu(){$(" #nav ul ").css({display: "none"}); // Opera Fix$(" #nav li").hover(function(){ $(this).children('ul').stop(true,true).animate({"opacity": 1}); },function(){ $(this).children('ul').stop(true,true).animate({"opacity": 0}); });} $(document).ready(function(){ mainmenu();}) But it doesn't work, did I miss something?
  12. Now, that's the code I'm looking for, however, it doesn't work for me..I think the target doesn't work or something?
  13. Hello, I've tried to do a Jquery dropdown on a menu but it only works one time. Is there any kind of toggle or something I should use instead. Do you have any soutions to a multilevel dropdown submenu? I'm very new to Jquery.. <ul> <li><a href="#">BlA</a></li> <li><a href="#">HTML</a></li> <li class="css"><a href="#">CSS</a> <ul class="subcss"> <li><a href="#">Box Model</a></li> <li><a href="#">Pseudo Classes</a></li> </ul></li> <!-- </li> sätts efter sub-menyerna --> <li><a href="#">JavaScript</a></li> </ul> $(function(){ $('.css').mouseover(function(){ $('ul>li').slideDown(); }).mouseleave(function(){ $('.subcss').slideUp(); });});
  14. Hi, I just started doing some javascript with jquery and I can't seem to make the code work.. I don't think javascript is "on" sort of speak. What have I done wrong? The tutorial is here: http://blog.themeforest.net/screencasts/jquery-for-absolute-beginners-video-series/ <!DOCTYPE html><html><head><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js" type="text/javascript"></script><link rel="stylesheet" href="html.css" type="text/css"></head><body><div id="box"></div><a href="#"> click me! </a></body></html> $(function)() {$('a').click(function() { $('#box').fadeOut();});}); #box {background:red;width:300px;height:300px;}
  15. I tried #picture { position:relative; float: right; right: 20px; bottom: 160px;} but I'm not sure if that was a good solution.. I had to figure out the size of the picture and then place it accordingly..
×
×
  • Create New...