Jump to content

mentalist

Members
  • Posts

    291
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by mentalist

  1. If i'm going to use a cookie anyway to allow some users to stay logged in, then since sessions throw a cookie anyway, why use both? *** unless I want to track visitors not logged in...
  2. Affect the CSS attribute of "ol" and change "start" to whatever number you want. For ordering, its either forward or backwards using the "reverse" attribute. Otherwise you'll need to build a list of all the list elements and manage it from there... but if you're doing that then it may be better to store the elements in an array or similar and manage from there...
  3. Where / how will you be storing each users playlist data?
  4. I'm working on a web app where data files are to be stored locally. Currently I simply include a single js file with a single function which returns json data. I'm about to start expanding that file to include a lot more levels, but the thing which gets me is that all that data is going to be in memory. So... what is the best way to just read local data when required? *** I heard something about the new HTML5 FileSystem API but haven't investigated it yet... Can any of you experts impart any wisdom please?
  5. Hi, I have a class object which needs to draw itself to a canvas and it needs to know which image to draw from. There are various ways I could do this, but... If when I create the object I pass the image to it, is that a copy of that image or just a reference to it? Here's a simplified scenario for example: var tileSheet=new Image();tileSheet.src="myImg.png";...var o = new dyn_char();Should I then do this:o.img = tileSheet;o.draw();or this: o.draw(img);Which is the more memory efficient way?
  6. First off start by working through a few tutorials, doing all the examples. Trial and error is the best way to understand! http://www.quirksmode.org/js/cookies.html http://www.w3schools.com/JS/js_cookies.asp
  7. Cheers! I'd investigated, checking for what was there using: var o; for(o in fruitsNodes[i].childNodes){ try { desc = fruitsNodes[i].childNodes[o]; } catch(e) { desc = "ERROR"; } alert("o: " + o + ", desc: " + desc); } I'd say it's a bit like Python's 'dir' function for javascript.
  8. Thankyou, that's a great help and shed some light as to why. I'd used this way by the end of last night (I'll add just for examples): fruitsNodes=xml.getElementsByTagName('fruit'); for (i=0;i<fruitsNodes.length;i++){ var name = fruitsNodes[i].getAttribute("name"); var colour = fruitsNodes[i].getAttribute("colour"); alert("Fruit " + name + " is coloured " + colour); } Slight changes, yet basically the same, but it's just the loop type from what I can see...
  9. It's been a while, but something like this... It also handles extra white space between words too! String.prototype.trim = function () { //return this.replace(/^\s*/, "").replace(/\s*$/, ""); return this.replace(/^\s+|\s+$/g, '') ; } var ss = " I told you it'd be alright! ".trim().replace(/\s+/g,' '); alert("ss: " + ss);
  10. Hi, I've found a few examples and references which all state this should work: <script> s=' \ <fruits> \ <fruit name="Apple" colour="Green" /> \ <fruit name="Banana" colour="Yellow" /> \ </fruits> \ '; function gen_xml(s){ if (window.DOMParser) { parser=new DOMParser(); xmlDoc=parser.parseFromString(s,"text/xml"); } else{ // Internet Explorer xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async="false"; xmlDoc.loadXML(s); } return xmlDoc; } function getFruits(xml){ var fruits = xml.getElementsByTagName("fruits")[0]; if (fruits) { var fruitsNodes = fruits.childNodes; if (fruitsNodes){ for (var i = 0; i < fruitsNodes.length; i++){ var name = fruitsNodes[i].getAttribute("name"); var colour = fruitsNodes[i].getAttribute("colour"); alert("Fruit " + name + " is coloured " + colour); } } } } xml=gen_xml(s); getFruits(xml); </script> But I keep getting the following error: Error: fruitsNodes[i].getAttribute is not a function Cheers!
  11. Sorry I should have specified the scope, basically all over... Also i'm not concerned about $a it was the memory usage of the class instantiation and how an unassigned class works. Cheers anyway.
  12. That's good enough for me, many thanks... class foo { public static function test($n) { if($n==1){ return "hello"; } else { return "goodbye"; } } } $a = foo::test(1); print $a; It's just I thought I may do away with so many globals for simple things, but for some things i'm not sure if the overhead will be worth it... Do you know how this works, say if I called it a second time, or another function within the class, would the class already be defined in memory or would it have already been destroyed and need to be initialised again?
  13. Hey, I've not used PHP for a while and never really used classes! I was reading some code today and I saw a statement something like: $s = &MyClass:"Something"); From reading the PHP Manual it has an example which looks like this for 5.3, however my server still uses 5.2 (.9), how do I do similar using that? Preferably something along these lines... class spook{ function __construct($n){ if($n==1){ return "hello"; } else { return "goodbye"; } } } $a=spook:); print $a; Cheers! i.e. What was the old method before the Scope resolution operator?
  14. Basically you will need to buy a / some SSL certificates.
  15. They used to be known as WYSIWYG editors, try another search there's loads out there... WYSIWYG = What You See Is What You Get
  16. You'll need to somehow identify each item in your list, probably by using id, then you'll need to (i'm assuming here) change the selected property from 'selected' to '' and vice versa, but that seems mad, so after a quick search... http://www.mredkj.com/tutorials/tutorial002.html
  17. You need the HTML 'onkeypress' attribute, but then to use JS. http://www.w3schools.com/jsref/event_onkeypress.asp
  18. mentalist

    Html Error

    Technically I can't see the problem. Some of your links need a space before the target attribute, but other than that their correct. Are you expecting the new page to be 'titled' as main, because it's not like that, internally the new tab / frame will be named 'main' internally and the title would be what ever is in the title tags in the actual page.
  19. Not sure what you mean... What is it supposed to do? If your on about what I think you mean, then i'm not sure if I should answer on here, but... Scraping (A scraper), basically fetch the page, split the page up with a DOM parser (html, xml, etc... (real issue is whether their well formed or not)), then identify appropriate links, then call the link... Sounds simple, and it is easier in PHP than a lot of other languages, but i'd not suggest it as a project for a beginner...
  20. FYI This type of file based database is known as a 'Flatfile Database'
  21. Sorry for my ignorance, I did however ask the if you could here on this site a few years ago... http://php.net/manual/en/language.references.pass.php
  22. Storing it and extra info is a trivial affair... To get it out, say have an img tag in your html which calls a php script, which uses something like the following... function dumip_it($s,$fn="fn.xml"){ header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.$fn); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: '.strlen($s)); ob_clean(); ob_flush(); print $s; exit; } Never actually got around to this, but it won't be far off...
  23. hmmm.... nc See here... http://uk2.php.net/manual/en/security.database.sql-injection.php Basically it suggests addslashes() amongst other things...
  24. I have three functions which look like this... function get_GET($name) { $sret=""; if(isset($_GET[$name])){ $sret=$_GET[$name]; $sret=mysql_real_escape_string($sret); } return $sret; }
  25. function dump_it($s,$fn="fn.xml"){ header('Content-type: text/xml'); header('Content-Length: '.strlen($s)); ob_clean(); ob_flush(); print $s; exit; }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.