• Questions That Don't Need Their Own Thread v3
    4,068 replies, posted
  • I'm just getting into JSON by looking at the fp api, I have [code] { "categories": [{ "name": "Facepunch", "forums": [{ "id": 6, "name": "General Discussion", "viewing": 86 }, { "id": 60, "name": "Fast Threads", "viewing": 108 }, { "id": 64, "name": "Videos And Flash Movies and That Kind Of Crap", "viewing": 51 }, etc [/code] I can't seem to get the name of one of the forums, I thought it was just something like: [code] $jsonDec = json_decode($var); $newVar = $jsonDec->categories->forums['2']->name; [/code] What am I doing horribly wrong? much appreciated!
  • [QUOTE=Snakess;35328048]I'm just getting into JSON by looking at the fp api, I have [code] { "categories": [{ "name": "Facepunch", "forums": [{ "id": 6, "name": "General Discussion", "viewing": 86 }, { "id": 60, "name": "Fast Threads", "viewing": 108 }, { "id": 64, "name": "Videos And Flash Movies and That Kind Of Crap", "viewing": 51 }, etc [/code] I can't seem to get the name of one of the forums, I thought it was just something like: [code] $jsonDec = json_decode($var); $newVar = $jsonDec->categories->forums['2']->name; [/code] What am I doing horribly wrong? much appreciated![/QUOTE] Try [code]$jsonDec->categories[0]->forums[2]->name[/code]
  • [QUOTE=TheDecryptor;35326527]No, it's the recommended doctype to use simply because it works in so many browsers (That is, it triggers standards mode in all browsers, you don't want to use quirks mode or a transitional doctype)[/QUOTE] Much appreciated!
  • [code] <input type="number" /> [/code] Anything similar to that but working in moz and ie as well? Integer only input.
  • [QUOTE=Miljaker;35328828][code] <input type="number" /> [/code] Anything similar to that but working in moz and ie as well? Integer only input.[/QUOTE] You need something like.. [url]http://validval.frebsite.nl/[/url]
  • [QUOTE=Sanya_Zol;35328866]You need something like.. [url]http://validval.frebsite.nl/[/url][/QUOTE] I need just this: [code] function is_int(value){ if((parseFloat(value) == parseInt(value)) && !isNaN(value)){ return true; } else { return false; } } function forceint(ele){ if(!is_int(ele.value)){ ele.value = 0; } } [/code] But it fails if someone disabled javascript. So I'd rather use something like type="number". But if there is nothing like that supported in all major browsers I guess I'll have to use javascript.
  • [QUOTE=Miljaker;35328828][code] <input type="number" /> [/code] Anything similar to that but working in moz and ie as well? Integer only input.[/QUOTE] Use Javascript for now. The new HTML5 input types are still in works and you can't rely on them but they are nice to use along side javascript validation. [editline]28th March 2012[/editline] [QUOTE=Miljaker;35329129]I need just this: [code] function is_int(value){ if((parseFloat(value) == parseInt(value)) && !isNaN(value)){ return true; } else { return false; } } function forceint(ele){ if(!is_int(ele.value)){ ele.value = 0; } } [/code] But it fails if someone disabled javascript. So I'd rather use something like type="number". But if there is nothing like that supported in all major browsers I guess I'll have to use javascript.[/QUOTE] Server-side validation is a must anyway.
  • [QUOTE=TheDecryptor;35326527]No, it's the recommended doctype to use simply because it works in so many browsers (That is, it triggers standards mode in all browsers, you don't want to use quirks mode or a transitional doctype)[/QUOTE] It's also recommended for HTML5 development right now if I recall isn't it? Is the standards mode literally the only reason it's being used right now? Because it's quite nice not having to use the long ass DocTypes that HTML/XHTML 4 uses currently.
  • Yeah, it's the official HTML5 doctype, but it was picked simply due to browser behaviour (in quirks mode/almost standards mode browsers ignore parts of the HTML/CSS specs on purpose) It has the benefit of being the most compatible doctype, and also being the shortest.
  • Interestingly enough my question is yet to be answered ([url]http://stackoverflow.com/questions/9863900/dynamic-methods-wont-work-in-app[/url])
  • [QUOTE=Crhem van der B;35342706]Interestingly enough my question is yet to be answered ([url]http://stackoverflow.com/questions/9863900/dynamic-methods-wont-work-in-app[/url])[/QUOTE] that makes no sense at all Can I see your schema.rb?
  • [QUOTE=swift and shift;35342957]that makes no sense at all Can I see your schema.rb?[/QUOTE] I completely agree with you, it doesn't. Here it is: [code] ActiveRecord::Schema.define(:version => 20120321200514) do create_table "posts", :force => true do |t| t.string "title" t.text "description" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false t.string "user" t.integer "user_id" t.integer "time" end create_table "users", :force => true do |t| t.string "name" t.text "password" t.text "pin" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false t.text "salt" end end [/code] P.S.: Yeah, I know some fields in "posts" table are not necessary, but I'm still learning, so didn't knew about some stuff.
  • Is there a way to make a form not submit to another page? I run this [code] <html> <body> <form > First name: <input type="text" name="FirstName" value="Mickey" /><br /> Last name: <input type="text" name="LastName" value="Mouse" /><br /> <input type="submit" value="Submit" /> </form> <p>Click the "Submit" button and the input will be sent to a page on the server called "form_action.asp".</p> </body> </html> [/code] and it insists on going to another page. I want to be able to press enter when I'm done and have the form submit itself. Looks like I'm gonna need to inject some javascript... right? I've actually never need to do this before... introsting..
  • [QUOTE=-Kesil-;35343516]Is there a way to make a form not submit to another page? I run this [code] <html> <body> <form > First name: <input type="text" name="FirstName" value="Mickey" /><br /> Last name: <input type="text" name="LastName" value="Mouse" /><br /> <input type="submit" value="Submit" /> </form> <p>Click the "Submit" button and the input will be sent to a page on the server called "form_action.asp".</p> </body> </html> [/code] and it insists on going to another page. I want to be able to press enter when I'm done and have the form submit itself. Looks like I'm gonna need to inject some javascript... right? I've actually never need to do this before... introsting..[/QUOTE] You need to use javascript to override the default behavior - which is to submit to the current address if no action attribute is given.
  • [QUOTE=-Kesil-;35343516]Is there a way to make a form not submit to another page? I run this [code] <html> <body> <form > First name: <input type="text" name="FirstName" value="Mickey" /><br /> Last name: <input type="text" name="LastName" value="Mouse" /><br /> <input type="submit" value="Submit" /> </form> <p>Click the "Submit" button and the input will be sent to a page on the server called "form_action.asp".</p> </body> </html> [/code] and it insists on going to another page. I want to be able to press enter when I'm done and have the form submit itself. Looks like I'm gonna need to inject some javascript... right? I've actually never need to do this before... introsting..[/QUOTE] Why not use post? method="post" action=""
  • Or, if he's using php, and the form page is called "form.php", he can just change to this: [code] <form action="form.php"> ... </form> [/code]
  • [php]<?php function NewColor() { $color = ""; $array = array( mt_rand(0,15), mt_rand(0,15), mt_rand(0,15), mt_rand(0,15), mt_rand(0,15), mt_rand(0,15), ); foreach ($array as $key => $value) { switch ($value) { case 10: $color .= 'a'; break; case 11: $color .= 'b'; break; case 12: $color .= 'c'; break; case 13: $color .= 'd'; break; case 14: $color .= 'e'; break; case 15: $color .= 'f'; break; default: $color .= $value; break; } } return $color; } $width = 101; $height = 101; $image = @imagecreate($width, $height) or die('Cannot initialize GD!'); $y = 1; while ($y !=$height) { $x = 1; while ($x != $width) { $rgb = NewColor(); $r = intval(substr($rgb, 0, 2)); $g = intval(substr($rgb, 2, 2)); $b = intval(substr($rgb, 4, 2)); imagesetpixel($image, $x, $y, imagecolorallocate($image, $r, $g, $b)); //echo("<p>".$x." - ".$y."</p>"); //imagesetpixel($image, $x, $y, imagecolorallocate($image, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255))); $x++; } $y++; } header('Content-Type: image/jpeg'); imagejpeg($image); imagedestroy($image); ?>[/php] This produces this: [img]http://puu.sh/mWBR[/img] Whereas it SHOULD be random pixels all over?
  • [url]http://lesscss.org/[/url] ^why isn't CSS like this by default? Is it just because they didn't think of it? [IMG]http://i.imgur.com/s8NL0.png[/IMG]
  • [QUOTE=-Kesil-;35344085][url]http://lesscss.org/[/url][/QUOTE] I like how you can define a constant! :D
  • [QUOTE=Crhem van der B;35343792]Or, if he's using php, and the form page is called "form.php", he can just change to this: [code] <form action="form.php"> ... </form> [/code][/QUOTE] Or he leaves it like I put it and it works, because you know, that just refers to the current page
  • [QUOTE=-Kesil-;35344085][url]http://lesscss.org/[/url][/QUOTE] [QUOTE]Chrome, Safari, Firefox[/QUOTE] So no IE and Opera?
  • [QUOTE=Miljaker;35344727]So no IE and Opera?[/QUOTE] Only if you're using the client-side script, which you shouldn't use in production.
  • Maybe I should start learning something about server stuff... I have no idea what to do to make a VPS working and host websites on it with features I can't do with shared hosting. But I don't see any way of learning it without first renting one, and it feels kinda stupid to spend money on something alien to me.
  • [QUOTE=SEKCobra;35345074]Uhm, just set one up on your home PC?[/QUOTE] On my acer laptop that overheats when I start up windows media player?
  • [QUOTE=Miljaker;35345063]Maybe I should start learning something about server stuff... I have no idea what to do to make a VPS working and host websites on it with features I can't do with shared hosting. But I don't see any way of learning it without first renting one, and it feels kinda stupid to spend money on something alien to me.[/QUOTE] Install a web server and away you go. Make multiple vhost's to point your domain's to the correct directory. Obviously you have to install languages you're using.
  • [QUOTE=jaybuz;35345146]Install a web server and away you go. Make multiple vhost's to point your domain's to the correct directory. Obviously you have to install languages you're using.[/QUOTE] I'd recommend setting up a linux installation on a virtual machine - you get to play around with a close-to-real-life environment in a controlled manner, without having to worry about screwing things up.
  • [QUOTE=Miljaker;35345129]On my acer laptop that overheats when I start up windows media player?[/QUOTE] 1: WMP is definitely more of a resource hog than apache with 1 client or less 2: It actually OVERheats when you do that? lmao