Jump to content
Larry Ullman's Book Forums

HartleySan

Members
  • Posts

    3047
  • Joined

  • Last visited

  • Days Won

    243

Posts posted by HartleySan

  1. Your problem is occurring because your append method call is destroying the old datepicker input element and adding a new one to the DOM, but the datepicker method call is (likely) setting up a click event handler for the old input, which is no longer in the DOM.

     

    Try adding the following line below the append method call (as well as retaining the call you already have):

    $("#datepicker").datepicker({dateFormat: 'yy-mm-dd'});
    • Upvote 1
  2. Hello and welcome to the forums.

     

    Obviously, there could be a number of factors, but if the DB isn't updating and you're not seeing any PHP errors, then very likely, the issue is with your query.

     

    Try echoing the generated UPDATE query string out to your browser, and then copy and paste that into phpMyAdmin or whatever, and see if you can execute the query directly on the DB.

    Likely, an syntax error will occur.

     

    Please let us know what you find.

    Thank you.

    • Upvote 1
  3. I've seen a lot of sites that put disclaimers near the submit button that say something like the following:

    "After clicking Submit, please wait a few moments and please do not click the Back button or close your browser."

     

    Beyond that, what can you do?

    At this point in the history of the Internet though, I think that people with slow connections have learned not to hit the Back button, etc. when the submit a form.

    And if they do hit Refresh or the Back button, what are you going to do if it's PHP only?

    There really is nothing.

     

    I guess my point is, you can only prevent idiots from hurting themselves to a certain point.

    Beyond that, it's not your concern.

  4. As far as I know, this is the intended behavior and most sites implement things this way.

    Granted, you could do a redirect, but that will make your code more complex and it seems like you're fighting intended and well-known behavior at that point.

     

    If you click on the URL bar and hit enter, it'll reload the page without posting the form.

    What I can't understand is if you're concerned about this for testing purposes or if you are concerned about your end users.

    In other words, what's the problem?

  5. You can do it either way. I was providing my way more as an example than as actual code that you should implement as-is. (Sorry, I should have explicitly stated that.)

     

    Anyway, if you want to do it your way with the array, but by applying the same principle, then what about the following:

    $pages = array(
      'Home' => 'index.php',
      'About' => '#',
      'Contact' => '#'
    );
    
    if (!isset(SESSION['user_id'])) {
      $pages['Register'] = 'register.php';
    }
     
    This is essentially the same as what you recommended, but it offers more flexibility with any links you may want to add in the future and/or make conditional.
    Also, you're welcome to question my code at any time. :)
     
    Edit: As a side note, I wouldn't recommend using an associative array (i.e., string keys) when you care about the order of your items (which I'm assuming you do).
    In all likelihood, PHP will retain the intended order of your nav links, but still, there's no reason PHP has to (after all, JavaScript does not in the same case), so it kind of scares me.
     
    The $pages array may be better implemented as follows:
    $pages = array(
      array(
        'label' => 'Home',
        'url' => 'index.php'
      ),
      array(
        'label' => 'About',
        'url' => '#'
      ),
      array(
        'label' => 'Contact',
        'url' => '#'
      )
    );
     
    The structure is a bit more complex, but not unnecessarily so, and you now have ultimate control and flexibility on how you present the nav via your data model.

    Just my two cents.

  6. Hello and welcome to the forums.

     

    There are quite a few problems with your code that seem to imply that you have a misunderstanding of many of the fundamentals of JS.

    I don't say that to be rude, but rather to suggest that I'm happy you want to learn how to do this on your own, and assuming that is the case, I would recommend buying Larry's JS book and going through it. It will explain everything you need to know to achieve what you want.

     

    Thanks.

    • Upvote 1
  7. It's because you're using single quotes instead of double quotes.

    Run your PHP and then look at the resulting source code. You'll see that each option element starts with the following:

    <option value="$key"selected="selected">

    Obviously, you don't want a value of "$key", and you don't want every option to have a value of selected, and you don't want the missing space between value and selected.

    Basically, you have a bunch of mistakes in your code.

    1. Change value="$key" to value="' . $key . '".
    2. Get rid of the semicolon at the end of the if statement.
    3. Add a space before selected="selected".
    4. Move the ">" after selected to the beginning of the echo $value statement.

     

    That should solve your problem.

    In the future, if you're having a problem, look at the source code resulting from the PHP code, and look for problems.

  8. You said that your POST array was empty when you posted the form, correct?

    If that's the case, then that is your problem.

     

    You need to figure out how to properly post your form.

    Start with a much simpler form, and get it to the point where it's properly posting, and then the problem should become clear.

     

    If the problem is related to something other than the POST array not being received, then you need to better describe your problem.

     

    ...And if you don't even know what your problem is, then you need to first work on better describing the problem for yourself before you try to explain it to us.

     

    Thank you.

×
×
  • Create New...