Jump to content

chibineku

Members
  • Content Count

    1,278
  • Joined

  • Last visited

Everything posted by chibineku

  1. Are you using the GET or POST method? GET has much stricter size limitations than POST and I'm not sure if trying to exceed it leads to clipping of the data being sent or if it causes form submission to fail.
  2. Not a good thing or a bad thing, but your code always looks incredibly complicated...
  3. HTML 5 will render a document missing html and body tags as if they were there. Valid, but poorly formed HTML 5: <!doctype html><title>This page is sucky</title><p>But it works!</p>
  4. Can you post code and a link to the page so we have something to go on?
  5. I think the problem is the chained .next() methods. Try splitting it into two statements, or try using .end() to reset the chain to $(this): $(this).next('.comment_post').slideUp(500).end().next('textarea.update_comment').slideDown(500);
  6. If your page has a width set, in %, px or whatever, then you can give it margin: 0 auto; to center it. Apply this to either the body or a containing element. It's with setting a width - most pages don't look good edge to edge.
  7. I liked this joke about programmers vs. engineers: Note: I ed for the exact wording and found that this joke has also been used as a mathematician vs. physicist joke, but it works exactly the same.
  8. chibineku

    random spaces

    The first step is to check if your page validates - both as XHTML 1.1 and CSS. The CSS is fine, but there are a number of problems with the XHTML, the first being that there is an error in your doctype: Fixing that might sort out some of your problems, since with an invalid doctype the page will probably revert to quirks mode.
  9. The array $a holds a list of words that can be used to provide an auto complete hint. The first loops works through each character of the query string $q and compares it to the elements in $a. If the two match, then $hint is set to the full entry in the suggestion array $a. As $q gets longer, the comparison can be made more accurately, so it will appear to refine the $hint. That might not have been the clearest explanation, but I hope it helped somewhat. Perhaps an example.If I type 'a', then $q == 'a'.The loop finds an entry from $a that starts with 'a' - let's say aardvark - and returns the hint $hint == 'aardvark'.Then I type 'ab', so the loops finds any entries starting with 'ab' and returns that - say 'abba'.Next I type 'aby' and the only word in the dictionary is 'abyss', so that is what $hint becomes. It's a constant refinement until the only viable option becomes apparent.
  10. There are errors on most complicated and sophisticated websites. Amazon has nearly 1000 errors and half again as many warnings. Some things work on some browsers and some things don't; some things affect the content and some don't. There are errors you can live with and those you can't. But validation is a factor in SEO, so it's a definite boon to a small website to validate. For the bigger sites that everyone knows by name and have already earned the top slot on google, it's not an issue anymore so they sacrifice standards for solutions. If you have a huge team of developers and content editors, there will be clashes and maintaining standards is probably nearly impossible all the time.
  11. chibineku

    DTD question

    The different DTDs determine which set of HTML elements are valid and how they're used and displayed. A strict DTD tends to get greater consistently across browsers and your CSS will be more robust. For example, if I use a strict DTD and change the padding of a div, the space around the content of the div increases, but the div stays the same size. If I increase the margin, the space around the div increases, but the size is the same. If I use a transitional doctype and change the padding of an element, it gets wider and taller by as much as the padding increase. If I change the margin, the div gets narrower. At least, that happens sometimes in IE - in other browsers, what happens when I make these changes is unpredictable. As a general rule, using a strict doctype, particularly XHTML 1.1 is the best practice. Your CSS changes will be easier because the results are predictable. Your site will look the same pretty much anywhere. I spent a frustrating hour trying to make simple changes to the layout of an ExpressionWeb template the other day until I checked the DTD and saw the evil word - transitional. I changed it to strict and had the page looking as I wanted it in 20 minutes.
  12. A final note:Adding the AJAX to the complete function of the animate method was the key, but because I was using .each() to fade in 4 elements, the AJAX fired 4 times, making the animation juddery. I changed the PHP to return the elements wrapped in a div and faded it in and out, and the result is smooth as the proverbial baby's bum.
  13. Ya, it's awesome - thanks!At a slow fade in, the new elements appeared to flicker, so I ditched the line setting the opacity of them to 0 and made the PHP echo the elements with the opacity already set to 0 - much smoother.
  14. I tried it on 3000ms and there was no fade out for me.
  15. Really? I still see it as vanishing and the new one fading in with no fade out. Strange. My brother on a different computer but also FF said the same thing.
  16. Okay, actually it isn't working right. It still skips to the fade in. I tried changing the position of the fade in to before the AJAX call, to after. Sometimes it hangs for a sec if positioned before the AJAX call. Here is what I'm using now: $(document).ready(function() { setTimeout("getTestimonial()", 10000);}); function getTestimonial() { var counter = $('#products #cart-widget .counter').html(); $('#products #cart-widget p > span').each(function(index) { if($(this).is('.counter')) { } else { $(this).animate({opacity: 0}, 1000, function(){}); } }); $.get("testimonials_include.php5", {'counter':counter}, function(data) { $('#products #cart-widget p').replaceWith(data); $('#products #cart-widget p').children().css("opacity",0);$('#products #cart-widget p > span').each(function(index) { if($(this).is('.counter')) { } else { $(this).animate({opacity: 1}, 1000, function(){}); }}); }); setTimeout("getTestimonial()", 10000); } You can see it here: testimonial box on right
  17. I changed it to the opacity version and it works with the 0/1 values as in your edit. Thanks! But still, it's annoying that the fadeOut method didn't work.
  18. Same thing - the old doesn't fade, just vanishes as the new one fades in. I tried moving the fade out bit before the AJAX call, but no change.
  19. I have an AJAX function that cycles through testimonials and fades the new one in, but for some reason the fadeOut() method won't work, despite the syntax being the same.Here is the function: $(document).ready(function() { setTimeout("getTestimonial()", 10000);}); function getTestimonial() { var counter = $('#products #cart-widget .counter').html(); $.get("testimonials_include.php5", {'counter':counter}, function(data) { $('#products #cart-widget p > span').each(function(index) { if($(this).is('.counter')) { } else { $(this).fadeOut('slow', function() {}); } }); $('#products #cart-widget p').replaceWith(data); $('#products #cart-widget p').children().css("display","none"); $('#products #cart-widget p > span').each(function(index) { if($(this).is('.counter')) { } else { $(this).fadeIn('slow', function() {}); } }); }); setTimeout("getTestimonial()", 10000); } I wasn't able to get the fadeIn to work until I had set the display of the new elements to none. I tried specifically setting the display of the existing elements to block before the fadeOut and still nothing.
  20. chibineku

    CSS margin problem

    Quick, change that transitional doctype to a strict one and watch the pieces fall into place!
  21. That's a good idea, DD, and I tried it, setting counter=1. As with the live page, the script seems to ignore the counter parameter and just delivers me a random result, which can have the same id as the counter parameter. Echoing $not made me realise that my ternary operator assignment wasn't working for some reason, but I changed it for a basic if and it works great now. I can't see what was wrong with the ternary statement, but anyhoo.Many thanks for the sound advice - I don't know why I don't already do these things, like echoing variables, as soon as I have a problem. I should know better by now.
  22. I have a PHP script which selects a random row from a database and echoes a formatted string. This is used at page load to display a random testimonial and the same script is used in an AJAX function to swap the testimonial every 5 seconds. I don't want to get the same testimonial twice in a row, so as part of the output there is a hidden span containing the id of the result row. I send this as a parameter in my AJAX function and want to exclude this id from the next select statement.Here is my current PHP script, with SELECT statement: <?phpinclude_once("db_include.php5");doDB();$not = (isset($_GET["counter"]))?"":"WHERE id NOT IN (".$_GET['counter'].")";$rand_sql = "SELECT * FROM edhypTestimonials $not ORDER BY RAND() LIMIT 1";$rand_res = mysqli_query($mysqli, $rand_sql) or error_log(mysqli_error($mysqli)."\r\n");$info = mysqli_fetch_array($rand_res); $search_res = ''; $id = $info["id"]; $name = $info["name"]; $testimony = $info["testimony"]; $search_res.= "<p><span class='counter' style='display: none;'>$id</span><span class='quote'>\"</span>$testimony<span class='quote'>\"</span><span class='name'>-$name</span></p>";echo $search_res;?> And here is the AJAX: $(document).ready(function() { setTimeout("getTestimonial()", 5000);}); function getTestimonial() { var counter = $('#products #cart-widget .counter').html(); $.get("testimonials_include.php5", {'counter':counter}, function(data) { $('#products #cart-widget p').replaceWith(data); }); setTimeout("getTestimonial()", 5000); } I am watching the console in Firebug and can see that the counter parameter is sent, but there must be something wrong with the SELECT as the same testimonial sometimes comes up several times in a row (there are only two entries in the database at present, just placeholders).I'm not good at making SQL queries but it doesn't seem like it should be any more complicated than that. Can anyone point me in the right direction?Additionally, the first time the script runs, as an include, it doesn't properly fetch a result, only once it's called by the jQuery function.
  23. I said the above code was the problem, and it's true that the logic seems to fail, but I preceded that code with: foreach($_COOKIE as $k => $v) { echo $k.": ".$v."<br />";} And it STILL didn't find the cookie I was looking for. It's most unusual.
×
×
  • Create New...