Jump to content

justsomeguy

Moderator
  • Posts

    31,575
  • Joined

  • Last visited

  • Days Won

    77

Posts posted by justsomeguy

  1. It might be an issue of 32-bit vs 64-bit, although a 64-bit OS should still be able to run 32-bit software.  If you right-click on My Computer and do Properties you'll see all of your info there.

  2. You need to get better at asking questions.  This is not a service where you enter your code and error message and a solution pops out.  Also, please understand how to post code using the Code button in the text entry field.

    The error message is telling you exactly what the problem is, do you understand what it's saying?

  3. Make addItem general, don't get the value to add from the page:

    function addItem(text){
        var ul = document.getElementById("dynamic-list");
        var li = document.createElement("li");
        li.setAttribute('id',text);
        li.appendChild(document.createTextNode(text));
        ul.appendChild(li);
    }

    The point is to remove the code that might change any time you want to call it, and instead pass those values to it.  Now you pass the value that you want to the function:

    addItem('Milk');
    addItem('Water');
    addItem(document.getElementById("candidate").value);
        <button onclick="addItem(document.getElementById('candidate').value)">add item</button>
        <button onclick="removeItem()">remove item</button>
        <button onclick="addItem('Water')">Water</button>
        <button onclick="addItem('Milk')">Milk</button>

     

  4. localStorage is just like sessionStorage, but sessionStorage only lasts while they're on your site, it won't be there if they come back.  localStorage will.  It's exactly the same to use it though, the difference is persistence.

  5. Your database should give you a function to convert a date where you tell it the format of the string to expect.  If you're trying to run it over the entire table then make sure there are no null values or other bad data.  A misspelled value in one row will cause it to break.

  6. It's not an issue of time.  Cookies are sent as HTTP headers with either the request or the response.  When your browser sends the HTTP request to the server, it includes any cookies that match the request as headers.  You can use your browser's developer tools to see that.  When the server is sending the response back, it will also send headers.  If your PHP code sets a cookie, then the response headers will include a Set-Cookie header to tell the browser to set a new cookie.  So when you set a cookie on one response you can't check the same cookie in that request.  That request was sent before the browser was told to set the cookie.  The cookie will be sent in the next request.

    • Like 1
  7. Change the function to add a new item so that you pass the value in instead of getting it from the input.  You can still use it with the regular add button:

    addItem(document.getElementById("myInput").value);

    Or you can call it with whatever other value you want:

    addItem('Milk');

  8. Changing a data structure in Javascript does not change files on disk.  Javascript running in a browser does not have permission to write to any files on your computer, thankfully.  If you want to change files on the server you need to use a server-side language like PHP for that.

  9. parseFloat does something different than what isNaN checks for.  isNaN converts to a Number, and then checks if that is NaN.  Converting to a Number is not the same as using parseFloat:

    var res = "";
      res = res + isNaN(123) + ": 123 -> " + Number(123) + "\n";
      res = res + isNaN(-1.23) + ": -1.23 -> " + Number(-1.23) + "\n";
      res = res + isNaN(5-2) + ": 5-2 -> " + Number(5-2) + "\n";
      res = res + isNaN(0) + ": 0 -> " + Number(0) + "\n";
      res = res + isNaN('123') + ": '123' -> " + Number('123') + "\n";
      res = res + isNaN('Hello') + ": 'Hello' -> " + Number('Hello') + "\n";
      res = res + isNaN('2005/12/12') + ": '2005/12/12' -> " + Number('2005/12/12') + "\n";
      res = res + isNaN('') + ": '' -> " + Number('') + "\n";
      res = res + isNaN(true) + ": true -> " + Number(true) + "\n";
      res = res + isNaN(undefined) + ": undefined -> " + Number(undefined) + "\n";
      res = res + isNaN(null) + ": null -> " + Number(null) + "\n";
      res = res + isNaN('NaN') + ": 'NaN' -> " + Number('NaN') + "\n";
      res = res + isNaN(NaN) + ": NaN -> " + Number(NaN) + "\n";
      res = res + isNaN(0 / 0) + ": 0 / 0 -> " + Number(0 / 0) + "\n";
    
    console.log(res)

    That shows the results that are expected.  I agree that isNaN should be associated with parseFloat and parseInt though, because that's usually when you need to test.  I typically convert first and then test to see if that result is NaN instead of using isNaN on the value to be converted.

  10. Do you want to do all of that in Javascript?  If so, put a handler on each dropdown that runs when the value is changed, and save the new value.  When the page is loaded check for that saved data and set the values of each field.

  11. There's not really a reason to use ORDER with UPDATE, it shouldn't matter what order the rows get updated.

    Update the playlist "Frank's Stuff" as a function of the track duration. 

    What does that mean?  Is the exercise to append the total duration to the playlist title?

  12. I've also read that if you invoke the session_start in more than 2 places it can screw things up.

    If you try to start the session while it is already started then PHP will show an error.  If it hasn't been started for that request then there's no problem.  Remember, every HTTP request is separate in PHP.  Starting a session in one request does not automatically start it in any other request.  It doesn't matter if it is an XHR request, or typing a URL and hitting enter, or clicking a link.  They're all just requests.

×
×
  • Create New...