• Questions That Don't Need Their Own Thread v3
    4,068 replies, posted
  • Avatar of icantread49
  • [QUOTE=swift and shift;35545762]subqueries are really bad for performance in mysql[/QUOTE] hm :| okay thanks for the tip, can you give me a hint on how to rewrite it?
  • Avatar of swift and shift
  • So usually if you have a subquery, you can refactor it into a join (most databases can do this automatically, mysql doesn't - hence why they're shit for performance) I'd probably write it like this: SELECT games.* FROM games INNER JOIN users_games ON users_games.game_id = games.id WHERE games.open = 1 AND users_games.user_id = 'bob' [editline]13th April 2012[/editline] also, if you have a users table, you should probably leave the username there and use the user's id as a foreign key rather than the username
  • Avatar of xmariusx
  • Needed some javascript, so I started [i]learning[/i] Javasscript some minutes ago! Why won't this work? [code] <div class="open-postform" onclick="showpostcomment()">Open</div> <div class="close-postform" onclick="hidepostcomment()">Close</div> [/code] [code] function showpostcomment() { var post = getElementByClass('postform'); post.style.height = '140px'; post.style.margin-top = '-15px'; } function hidepostcomment() { var post = getElementByClass('postform'); post.style.height = '0px'; post.style.margin-top = '0px'; } [/code] Any good and free JS tutorials out there?
  • Avatar of TheBigS
  • [QUOTE=xmariusx;35553550]Needed some javascript, so I started [i]learning[/i] Javasscript some minutes ago! Why won't this work? [code] <div class="open-postform" onclick="showpostcomment()">Open</div> <div class="close-postform" onclick="hidepostcomment()">Close</div> [/code] [code] function showpostcomment() { var post = getElementByClass('postform'); post.style.height = '140px'; post.style.margin-top = '-15px'; } function hidepostcomment() { var post = getElementByClass('postform'); post.style.height = '0px'; post.style.margin-top = '0px'; } [/code] Any good and free JS tutorials out there?[/QUOTE] Give your "postform" dom element (whatever it is you are showing and hiding) an id of "postform" if you haven't already, and then in each function, change getElementByClass to getElementById - I should think that would do it. I don't even think getElementByClass is an actual function (there's GetElementsByClassName but that returns an array of all objects with that class)
  • Avatar of xmariusx
  • [QUOTE=TheBigS;35553606]Give your "postform" dom element (whatever it is you are showing and hiding) an id of "postform" if you haven't already, and then in each function, change getElementByClass to getElementById - I should think that would do it. I don't even think getElementByClass is an actual function (there's GetElementsByClassName but that returns an array of all objects with that class)[/QUOTE] Didn't do the trick :/ [editline]o[/editline] Chrome error in the inspector: Uncaught ReferenceError: getElementById is not defined Uncaught ReferenceError: getElementById is not defined
  • Avatar of xmariusx
  • [QUOTE=eternalflamez;35553697]Care to upload the entire script somewhere? It can't be that large.[/QUOTE] That is the entire Javascript, have I done something wrong? :S
  • Avatar of eternalflamez
  • Ok but with the Html? [editline]13th April 2012[/editline] And you changed it to go for elementID instead of the class, maybe you did something wrong there? [editline]lol[/editline] Lol TheBigS you are right there too. I missed it too, because he didn't use it in the original script either. xmariusx read the below, that will do. (Which would have been spotted anyway if you had showed us the updated script, but w/e) | | V
  • Avatar of TheBigS
  • [QUOTE=eternalflamez;35553697]Care to upload the entire script somewhere? It can't be that large.[/QUOTE] I'm an idiot... before getElementById put document... document.getElementById('postform') will work ALSO it's style.marginTop for your top margin.. no dashes, and make sure to capitalize the T
  • Avatar of xmariusx
  • [QUOTE=TheBigS;35553772]I'm an idiot... before getElementById put document... document.getElementById('postform') will work ALSO it's style.marginTop for your top margin.. no dashes, and make sure to capitalize the T[/QUOTE] Thanks it worked, thanks to both of u for helping! :) learned about the document. thing, but forgot. Feel like an idiot now :D Thanks again
  • Avatar of Wickedgenius
  • I've got a form that is loaded and refreshed using AJAX (not the jQuery AJAX functions though) and I now want to add some jQuery UI stuff (mainly sliders) to this form but can't seem to get them to show up after the form has been loaded or when it is refreshed. Any ideas on how I can do this or why it wouldn't work or would some code snippets help more?
  • Avatar of Sanya_Zol
  • [QUOTE=Wickedgenius;35557527]I've got a form that is loaded and refreshed using AJAX (not the jQuery AJAX functions though) and I now want to add some jQuery UI stuff (mainly sliders) to this form but can't seem to get them to show up after the form has been loaded or when it is refreshed. Any ideas on how I can do this or why it wouldn't work or would some code snippets help more?[/QUOTE] Obviously, you should &#822;l&#822;o&#822;a&#822;d&#822; &#822;a&#822;n&#822;d&#822; refresh form using jQuery functions. jqUI designed for jquery, not pure javascript form manipulation.
  • Avatar of Wickedgenius
  • [QUOTE=Sanya_Zol;35557639]Obviously, you should &#822;l&#822;o&#822;a&#822;d&#822; &#822;a&#822;n&#822;d&#822; refresh form using jQuery functions. jqUI designed for jquery, not pure javascript form manipulation.[/QUOTE] Thanks, turned out my only problem in the end was that I had put a # at the start of the elements id, next time I'm just posting my code straight away so someone can point out how I'm being a muppet!
  • I'm not sure this is where this goes, but I need some help. I'm working on a site for a class. Really basic stuff. The university grants us space on their server for it. I'm using Dreamweaver CS5, and Filezilla to transfer. The page is going through fine, but none of the images are. Should look like: [IMG]http://i.imgur.com/43qjM.png[/IMG] But instead I get: [IMG]http://i.imgur.com/rcV1y.png[/IMG] The images all seem transferred and whatnot. I'm wondering what my problem is. I'm pretty sure I had this same problem earlier, and I fixed it, but I forget how. Anyone got any clues? I know about zip on this type of shit. Most of the work is done on the school MACs, I'm building and using files from my home PC now, if that's a thing. SFTP connection or whatever.
  • Avatar of Miljaker
  • [QUOTE='[Seed Eater];35560741']I'm not sure this is where this goes, but I need some help. I'm working on a site for a class. Really basic stuff. The university grants us space on their server for it. I'm using Dreamweaver CS5, and Filezilla to transfer. The page is going through fine, but none of the images are. Should look like: But instead I get: The images all seem transferred and whatnot. I'm wondering what my problem is. I'm pretty sure I had this same problem earlier, and I fixed it, but I forget how. Anyone got any clues? I know about zip on this type of shit.[/QUOTE] did you upload the files? what is the image url? if its in the same folder as your html file it should be just "image.jpg" not "documents/users/stuff/image.jpg" Show the code.
  • [QUOTE='[Seed Eater];35560741']I'm not sure this is where this goes, but I need some help. I'm working on a site for a class. Really basic stuff. The university grants us space on their server for it. I'm using Dreamweaver CS5, and Filezilla to transfer. The page is going through fine, but none of the images are. The images all seem transferred and whatnot. I'm wondering what my problem is. I'm pretty sure I had this same problem earlier, and I fixed it, but I forget how. Anyone got any clues? I know about zip on this type of shit. Most of the work is done on the school MACs, I'm building and using files from my home PC now, if that's a thing. SFTP connection or whatever.[/QUOTE] If it's a Linux server it's hosted on then case sensitive file names may be the issues, it's happened to me a few times, eg, images/landscape.jpg is different to Images/LandScape.jpg
  • [QUOTE=Miljaker;35560872]did you upload the files? what is the image url? if its in the same folder as your html file it should be just "image.jpg" not "documents/users/stuff/image.jpg" Show the code.[/QUOTE] Thanks for the help, but I just figured it out, and like last time I facepalmed because it was so simple. My files needed to be at the host location for the site or whatever the correct terms are. Basically, all info for the site is set up on my I/ drive, and the reason why none of the files weren't showing was because they were not on that drive. They needed to be. Tah dah.
  • Alright, round 2. For whatever reason, I get to class today and check out the site, planning to work with it more, and on Firefox, on the class Mac, the bloody background image on the index page only has changed bloody colors to a darker shade. The image itself is no different, but whenever I apply it as a background image to a page, at least here, in Firefox and Safari, the background is a darker shade on the website (or header image becomes lighter shade. I don't know for certain. One of the two changes when the pair is bg3.png and name2.png, but I don't get a problem with any other background). Don't blame me if the code is shit, blame Dreamweaver. This is the index code: [code] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>The Best Index on Earth</title> <style type="text/css"> body { background-image: url(bg7.png); background-repeat: repeat-x; margin-top: 24px; background-color: #D40510; } </style> <script type="text/javascript"> function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } </script> <link href="NoBorder.css" rel="stylesheet" type="text/css" /> </head> <body onload="MM_preloadImages('file:///C|/Users/DP/Pictures/ButtonLinks2.png','ButtonAbout2.png','ButtonArt2.png')"> <div align="center"> <p><img src="name2.png" alt="name" width="800" height="162" align="center" border="0"/></p> </div> <div align="center"> <table width="806" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="100"><table width="806" border="0" cellpadding="0" cellspacing="0"> <tr> <td><div align="center"> <table width="806" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="806" height="100"><a href="about_test.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image2','','ButtonAbout2.png',1)"><img src="ButtonAbout1.png" name="Image2" width="260" height="400" border="0" id="Image2" /></a><a href="gallery.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image3','','ButtonArt2.png',1)"><img src="ButtonArt1.png" name="Image3" width="266" height="300" border="0" id="Image3" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image4','','ButtonLinks2.png',1)"><img src="ButtonLinks1.png" name="Image4" width="266" height="200" border="0" id="Image4" /></a></td> </tr> </table> <a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Links','','file:///C|/Users/DP/Pictures/ButtonLinks2.png',1)"></a></div></td> </tr> </table></td> </tr> </table> </div> </body> </html> [/code] Comparatively, this is the about page code, without the background problem: [code] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Aboot</title> <style> a img { border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border: none; }a img { border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; } </style> <style type="text/css"> body { background-image: url(bg4.png); background-repeat: repeat-x; margin-top: 24px; background-color: #D40510; } </style> <link href="NoBorder.css" rel="stylesheet" type="text/css" /> </head> <body> <div align="center"> <p><a href="index.html"><img src="name2.png" alt="name" width="800" height="162" align="center" border="0"/></a></p> </div> <p>&nbsp;</p> <p>&nbsp;</p> <p>&nbsp;</p> <p>&nbsp;</p> <p>&nbsp;</p> <p>I am a full-time commuter student at Eastern Michigan University, majoring in political science. I currently live in Dexter, Michigan.</p> </body> </html> [/code] If the problem is in there, let me know where. I can't for the life of me figure out why it's only that one image. I haven't modified the background image at all, the colors are exactly identical when I open the images in Photoshop, yet for this specific page, or this specific image, it bugs the hell out of me. Clarification: How it ought to look vs What I'm getting [t]http://i.imgur.com/x5Y06.png[/t] [t]http://i.imgur.com/i2zPR.png[/t] Apparently the problem is Firefox exclusive.
  • Avatar of jung3o
  • [QUOTE='[Seed Eater];35567479']Alright, round 2. For whatever reason, I get to class today and check out the site, planning to work with it more, and on Firefox, on the class Mac, the bloody background image on the index page only has changed bloody colors to a darker shade. The image itself is no different, but whenever I apply it as a background image to a page, at least here, in Firefox and Safari, the background is a darker shade on the website. Don't blame me if the code is shit, blame Dreamweaver. This is the index code: [code] <body onload="MM_preloadImages('file:///C|/Users/DP/Pictures/ButtonLinks2.png','ButtonAbout2.png','ButtonArt2.png')"> </html> [/code] If the problem is in there, let me know where. I can't for the life of me figure out why it's only that one image. I haven't modified the background image at all, the colors are exactly identical when I open the images in Photoshop, yet for this specific page, or this specific image, it bugs the hell out of me.[/QUOTE] fix that. Also, I heard DW is fine it's the person who uses it.
  • [QUOTE=jung3o;35567518]fix that. Also, I heard DW is fine it's the person who uses it.[/QUOTE] [del]Fix what?[/del] Fixed that. And I'm not saying it's shit, I'm saying that I didn't change any of the code. I don't know shit about any of this, you gotta walk me through this in baby steps, here. I have a whole week of this stuff under my belt. [editline]14th April 2012[/editline] Apparently the problem is exclusive to Firefox. Safari and Chrome work fine.
  • Avatar of TheLastNomad
  • I only saw this thread after I made my own asking a stupid question. So i guess I'll ask that question here instead. I'm trying to link a HTML page I'm making to multiple style sheets and this is the code I have in the <head> tag [code]<link rel="stylesheet" type="text/css" title= "default" href="style.css" /> <link rel="alternate stylesheet" type="text/css" title= "OtherStyle" href="style2.css" /> [/code] but it doesn't work. Could anyone maybe help me out and let me know whats wrong. It would be greatly appreciated. EDIT: I'm not trying to get the two to work at once, I'm trying to get the page to be able to switch between the two.
  • Avatar of CBastard
  • [QUOTE=TheLastNomad;35568382]I only saw this thread after I made my own asking a stupid question. So i guess I'll ask that question here instead. I'm trying to link a HTML page I'm making to multiple style sheets and this is the code I have in the <head> tag [code]<link rel="stylesheet" type="text/css" title= "default" href="style.css" /> <link rel="alternate stylesheet" type="text/css" title= "OtherStyle" href="style2.css" /> [/code] but it doesn't work. Could anyone maybe help me out and let me know whats wrong. It would be greatly appreciated. EDIT: I'm not trying to get the two to work at once, I'm trying to get the page to be able to switch between the two.[/QUOTE] So you want to swap the rel attributes with Javascript.
  • Avatar of TheDecryptor
  • [QUOTE='[Seed Eater];35567564'][del]Fix what?[/del] Fixed that. And I'm not saying it's shit, I'm saying that I didn't change any of the code. I don't know shit about any of this, you gotta walk me through this in baby steps, here. I have a whole week of this stuff under my belt. [editline]14th April 2012[/editline] Apparently the problem is exclusive to Firefox. Safari and Chrome work fine.[/QUOTE] It's because you're using a colour profile in the image, Firefox/Safari/IE9 all do colour correction by default. It'll vary between computers based on what colour profile the monitor has (sRGB will result in basically no correction, while OS X will auto-generate a custom one, etc.)
  • Avatar of TehWhale
  • [url=http://pastie.org/3789263]What's wrong with this code? It doesn't seem to set the default value for admin and banned.[/url] [editline]14th April 2012[/editline] uhm, nevermind
  • Avatar of rookwood101
  • Is anyone else getting this problem in firefox with making triangles using css?: [IMG]http://i.imgur.com/H1tnj.png[/IMG] I try any other browser and they look like this: [IMG]http://davidwalsh.name/dw-content/css-triangles.png[/IMG] The code to make them is well documented: [URL="http://davidwalsh.name/css-triangles"]http://davidwalsh.name/css-triangles[/URL] and looking around I can't find anyone with the same problem as me. Any of you guys know what's going on?
  • Avatar of TheLastNomad
  • [QUOTE=CBastard;35570496]So you want to swap the rel attributes with Javascript.[/QUOTE] Yeah, I don't know so much about Javascript yet, but it looks like I'll probably have to use it.
  • Avatar of TheDecryptor
  • [QUOTE=rookwood101;35579086]Is anyone else getting this problem in firefox with making triangles using css?: [IMG]http://i.imgur.com/H1tnj.png[/IMG] I try any other browser and they look like this: [IMG]http://davidwalsh.name/dw-content/css-triangles.png[/IMG] The code to make them is well documented: [URL="http://davidwalsh.name/css-triangles"]http://davidwalsh.name/css-triangles[/URL] and looking around I can't find anyone with the same problem as me. Any of you guys know what's going on?[/QUOTE] Tried disabling hardware acceleration? It works fine for me here.
  • Avatar of rookwood101
  • [QUOTE=TheDecryptor;35579504]Tried disabling hardware acceleration? It works fine for me here.[/QUOTE] Hah thanks it works now :)
  • Avatar of swift and shift
  • [QUOTE=TehWhale;35573506][url=http://pastie.org/3789263]What's wrong with this code? It doesn't seem to set the default value for admin and banned.[/url] [editline]14th April 2012[/editline] uhm, nevermind[/QUOTE] why do you have an add_column as well as a create_table? Just create all the columns you want inside the create_table