Jump to content

obsidian

Staff Alumni
  • Posts

    3,202
  • Joined

  • Last visited

Posts posted by obsidian

  1. why would you use those?

     

    Base href can be very useful when working in the confines of a larger scale system (such as a CMS) when different environments are needed. For instance, in a preview or dev environment, being able to set the base href to a location where all scratch versions of pages (and everything else, for that matter) reside can be extremely useful. Additionally, if you set all the links in an application to the web root by using absolute paths, you run into the problem of that application always having to be installed at the web root. Setting the base href can be very useful to overcome this challenge by allowing the base href to be a configuration variable so that all links within a given code base will reference the same base.

     

    So, as you can see, there are definitely viable reasons to use the tag, although it is definitely not always the best solution for path fixes, especially when using in-page anchors.

  2. Try something like this, replacing your variables or values where appropriate:

    <?php
    $sql = mysql_query("SELECT COUNT(post_id) FROM posts WHERE DATE(post_time) = CURDATE() AND posted_by = $user_id");
    if (mysql_num_rows($sql) == 0)
    {
      // User has not posted today, so show the link
    }
    ?>
    

  3. You compared flash to java though, you do know java is a full-featured programming language, not just a way of making web applets, yes?

     

    Also, please don't confuse Java with JavaScript. Java, as was just mentioned, is a fully featured programming language while JavaScript in web is simply a client side scripting language to add some dynamic elements to the page. JavaScript would be much more comparable to flash than Java.

  4. basicaly i was managing around 30 sites at once and i needed a free IDE for home use but all the ones i tried would not let me save (local server, remote server) as a saved site and then reload it anytime from a list.

     

    The difference between Dreamweaver and other IDEs, in my opinion, is that Dreamweaver is geared towards the common user while other IDEs expect that you will set up your own local/remote information - whether that be SFTP or CSV/SVN. As mentioned previously, nearly every IDE offers the support to do what you are mentioning, but you have to set it up manually to your own specifications.

     

    I would add NetBeans as another free IDE to look at as well.

  5. when class fridge is instantiated a dictionary list (optionally passed in), will be created and assigned to items

     

    Correct, although, as with PHP, that definition is setting a default value for the optional parameter. You can provide a dictionary as a parameter to be assigned to the member variable items instead of letting an empty one be assigned, if you choose.

  6. First, self is the referencing term for the current object, just like $this in PHP. What is odd is that, in Python, you have to always define your member variables as passing the object itself as the first argument (which is done by default); hence the appearance of the "self" in the __init()__ function.

     

    The self.items = items line actually assigns the passed parameter of items to an instance variable within the object itself. And, no, the return is not specifically needed.

  7. Using Javascript validation for form input is a really bad idea...

     

    Yes and no. To solely rely on JavaScript is a bad idea for the reasons provided; however, many users will prefer to be warned of faulty data before they have to leave the page, so using some JavaScript validation in conjunction with PHP validation on the receiving end is definitely a good idea.

     

    Now, in answer to the original post, I don't see where you are actually calling the validation on submit. You have the validate_form and validate_email functions defined, but you never attach the validation to the form submit event. The easiest way to do this is to call your function in the onsubmit attribute of the form tag. Remember that if you return FALSE from an onsubmit, the form will not process:

    <script type="text/javascript">
    function my_simple_validation (field)
    {
      if (field.value == '')
      {
        alert('You must fill in required fields!');
        return false; // This is where you tell the form not to submit
      }
    
      return true; // if we pass, submit the form
    }
    </script>
    
    <form name="my_form" action="process.php" method="post" onsubmit="return my_simple_validation(this.email);">
    ...
    

     

    Obviously, this is generic code, but it should give you the principles needed.

     

    Good luck!

  8. Ok, its not me. My  [  i  ]  is being removed by this forum

     

    alert(start3[i]);
    

    is what I want

     

    Yes, the square braces with the nested 'i' you are attempting to put in your text is the BBCode for italic, so it gets parsed out. So, with the start3 sub i, is your problem fixed, or do you still have a question?

  9. Well, first of all, to hide them, you simply would attach a class with the CSS attribute of "display: none" ... then, when there is a focus given to the last textarea, you can display the next one in line. Something like this should get you in the right direction:

     

    First, create our textboxes and generate helpful IDs to use:

    <?php
    for ($i = 1; $i <= 50; $i++)
    {
      echo "<textarea name=\"mybox[]\" cols=\"60\" rows=\"8\" id=\"textbox-{$i}\" onfocus=\"showNextBox({$i});\"";
      echo ($i > 5) ? ' class="hidden"' : ' class="shown"';
      echo "></textarea>\n";
    }
    ?>
    

     

    Then, the supporting CSS to hide and show the boxes:

    .hidden {
      display: none;
    }
    
    .shown {
      display: block;
    }
    

     

    Finally, we write our JavaScript showNextBox() function to support the code above:

    function showNextBox(i)
    {
      var id = 'textbox-' + (i + 1); // Next incremental box
      var el = document.getElementById(id);
      el.className = 'shown';
    }
    

     

    Hope this helps.

  10. So what's the consensus?  Is LISP worth learning?  Or is it basically a waste of time?

     

    I personally think it is well worth learning. I've done the basic curve for learning LISP myself, and it definitely helps with breaking down the larger problems into manageable chunks. The implementation of LISP is a bit confusing at first, but I have been rather impressed with its speed and ease of learning.

     

    I also like the way they encourage you to learn proper use of the lambda notation:

    (every #'(lambda (n) (not (oddp n))) '(2 4 6 8 10))
    

     

    Very cool stuff ;)

  11. This may be old news to some, but I have recently (in the last month) been introduced to the world of the Google App Engine. I had looked into Python a little in the past, but with this amazing tool, I have given it a second glance, and I have to say that I'm rather impressed with the power it has - even for web applications.

     

    I have always wanted to write a little tactics style game using AJAX and JavaScript animation for fun, and in a matter of just a couple days, I've been able to write Python classes to support the mapping and basic unit mechanisms and movement.

     

    Has anyone else delved into the world of Python for web (with or without Google App Engine) and found any good resources? It seems like this might be a good language to add to my skill set, and it has proven extremely easy to learn thus far. I'm interested to hear any input or discoveries from others in the community as well.

  12. using Mchl's code, could I find a bouce rate percentage?

     

    bounce rate = The percentage of visits where the visitor enters and exits at the same page without visiting any other pages on the site in between.

     

    $pagesAccessed = 1000;
    $uniquePeople = 100;
    
    $bounceRate = ($uniquePeople / $pagesAccessd) * 100;

     

    You really can't find a bounce rate unless you know exactly how many pages came from each individual user. Your number of page hits really doesn't apply to the bounce rate average, since "bounce" is actually like a boolean for each user. So, if you have hits per user, you could calculate it if you're careful.

  13. How does Google Analytics check to see if the user requesting a page has JavaScript on or off?

     

    I don't think that is possible. If you use Google Analytics, you'll notice that it is simply an inclusion and call to a Google API. If the user has JavaScript turned off, the call never gets made to the API. If, on the other hand, you are referring to the browser capabilities tab labeled Java Support, it is just that - not JavaScript.

  14. First question: why are you using tables for this?

     

    To answer your question directly, since you are using visibility to change the appearance, the physical location of the div is still retained in the rendering. If you use display: none and display: block instead of visibility: hidden to show and hide the divs, you may be better off across browsers.

  15. I'd say $row['uniqueCount'] / $row['totalCount']

     

    Wouldn't that always return a number less than 1, though? I think he has the right of it, since he wants an average number of page hits per visit... so:

     

    <?php
    $total = 100; // 100 page hits
    $users = 10; // 10 unique visitors
    $avg = $total / $users; // 10 hits per visitor
    ?>
    

     

    This would not be accurate:

    <?php
    $total = 100; // 100 page hits
    $users = 10; // 10 unique visitors
    $avg = $users / $total; // 1/10 hits per visitor -- makes no sense
    ?>
    

  16. If you do a little Googling on the topic, you will quickly discover that, due to the type of data being transfered with file uploads, it cannot be accomplished with a typical AJAX request. Therefore, the solution most typically used is to take the form values and submit them (a true submit, mind you) through a hidden iframe or something like that to keep the main page from refreshing. So, it is not truly an AJAX upload, but to the user, it is the same effect.

  17. If I understand your issue right, you are wanting to turn off the debug mode so that the alert box does not appear on every page. If so, consider the following line:

    function cdLocalTime(container, servermode, offsetMinutes, targetdate, debugmode)
    

     

    If you pass in the final parameter (no matter what it is), the debugmode of the object is set to 1 (or on). So, wherever you call cdLocalTime(), you need to be sure you have only 4 parameters and not 5. Removing the 5th parameter will turn off debug mode for you.

  18. Let me step out on a limb here and say that a RIGHT JOIN is very seldom what you want to use for any sort of basic querying. They don't behave like people assume. You probably want to be using INNER JOIN instead. Try this:

    SELECT p.products_model, p.products_image, p.products_price
    FROM products p
    INNER JOIN products_to_categories ptc ON ptc.products_id = p.products_id
    WHERE ptc.categories_id = 'whatever'
    AND p.products_quantity > 0
    AND p.products_status = 1
    ORDER BY p.products_ordered DESC
    LIMIT 1
    

  19. I've seen tons of horrible JavaScript snippets all over the internet.  I mean HORRIBLE.

     

     

    Edit: That wasn't a direct jab at dynamicdrive.  Just meant to say there's a lot of garbage out there, so people who don't know JS should be careful.

     

    Definitely agree. In addition, I would take it a step further and say that I have seen many horrible scripts offered on tutorial and other seemingly "professional" coding sites. Many people who are developers do not take the time to learn JavaScript well, and as with any language, just settling for getting something to work is not always the best approach. Read and learn the best way to handle it and make sure that the code base is solid.

×
×
  • 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.