Jump to content

Irate

Members
  • Posts

    354
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Irate

  1. As .josh stated in an announcement in here, use jQuery for Ajax requests. It is A LOT easier than re-inventing the same wheel over and over again.
  2. Use a conditional statement. $stock = ($product_record->Available_Stock > 100) ? $product_record->Available_Stock - 100 : 0;
  3. Better yet, if you're looking for an extensive, intricate book on JavaScript, check out David Flanagan's JavaScript: The Definitive Guide (it's around 60$ or 42€, but it is worth it, plus, it has cheaper, digital copies).
  4. Have you read JavaScript: The Definitive Guide by David Flanagan? You could try using parentheses around the expression followed by a ?: operator (like return (a==b&&c!=d) ? e : f;) such as to not always confuse the reader (given they know about (the) ternary operator and logical operators), but in this case, writing a more elaborate conditional statement with ifs and elses is appropriate, I'd say.
  5. It isn't. You can however emulate this perfectly for IE. (function(e){if(e&&e.prototype.addEventListener)return e.prototype.addEvent=e.prototype.addEventListener;if(e&&e.prototype.attachEvent)e.prototype.addEvent=addEvent;function addEvent(ev,f){this.attachEvent('on'+ev,f);return this;}})(HTMLElement);Should work. Untested, might have mistyped on my phone.
  6. Just some brief note, if you crucially rely on the information you get from the script you're building, works with integers instead of floats. Floats have rounding errors in all programming languages with the IEEE-754 standard, which causes simple computations to receive minimal errors, like this. $a = 0.1; $b = 0.2; $a + $b === 0.3; // false!
  7. So, thought I'd give you some kind of update, but IE 11 is now released, and it seems that Microsoft has finally (after over 2 years) managed to support HTML5 and that the new JS Engine is a lot faster than IE 10's. Opinions on this?
  8. Uh, yeah, that's true... Well, nevermind me, then...
  9. Try using a plain for loop and capture the increment value? function arrayIndex( $arr, $elem ) { if(gettype($arr)!=="array") return; if(count($arr)==0) return -1; for($i = 0; $i < count($arr); $i++) { if($arr[$i]==$elem) return $i; } return -1;The code doesn't do any recursive scanning, though.I'll need to find a workaround for that.
  10. Possible, yes, but it's easier in SASS/LESS. After all, SASS and LESS compile into CSS3 stylesheets.
  11. You should try SASS / LESS.
  12. What have you tried so far? Where are you stuck?
  13. JavaScript and PHP do completely different things. PHP works as hypertext preprocessor (hence its name, "PHP: Hypertext Preprocessor") and does not generate any events in the browser, it just helps to dynamically display content by querying databases or by checking unique identifiers given. JavaScript is client-side and gives you options to modify the document content, send asynchronous HTTP requests and generally does not provide dynamic content (unless you send, as mentioned before, HTTP requests). If the file you want to include contains pieces of JavaScript and you set the HTTP Content-Type to "application/javascript" (or for older browsers, "text/javascript"), you can do this. <script src="myfile.php" type="text/javascript"></script> Otherwise, you can echo content into the script tag itself. <script type="text/javascript"><?= $yourVariable ?></script>
  14. Rule of thumb, never trust anything that comes from the client side, you never know if it has been tampered with.
  15. Nothing. Just saying that Google should kinda unflag them.
  16. This is serious biz man, how's Google gonna flag the ones who developed the main language they're using?
  17. It depends on the charset, maybe the £ sign is represented by control characters (for whatsoever reason) and breaks the BBCode? £ works, I guess?
  18. Use code tags when posting code, please. The escape function is called mysql_real_escape_string, and you should generally avoid usint mysql_* function because the native support it had will be removed in further distributions of PHP. It's already deprecated in older code. Use mysqli or PDO instead, anyway.
  19. You can also use bind, too, which accepts any amount of event binders as space-separated list, "mouseenter mouseleave" for example (which would equal hover, anyway).
  20. Hrmpf, I guess my reading skills were better at another time. I apologize.
  21. Right. That is easy, of course. I would need to see the actual form you have created for that, MathiVel.
  22. Rename index.php to index2.php?
  23. Try .htaccess to generate 403 errors when accessing the script, if you have an Apache server running. ErrorDocument 403 /path/to/file.php
  24. Try parse_url, too. You can just easily get the host name with that.
  25. Don't validate anything with JavaScript what you can validate with PHP. Just don't. Edit: ... Of course, I'm implying that your JavaScript implemntation is not found on your server. If it was a server-side implementation of JS, then go ahead. If you mean the client-side JS with the Document Object Model, then forget about it.
×
×
  • 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.