Jump to content

Ingolme

Moderator
  • Posts

    14,901
  • Joined

  • Last visited

  • Days Won

    177

Everything posted by Ingolme

  1. The first thing you should do is try the code yourself to see if it works. I don't see any obvious errors, so I would guess that it does work, but is unsafe on a few levels. I've removed the database information from your post to keep your accounts safe from people reading the forum. Your SQL query is open to SQL injection. Read about prepared statements to keep your database safe from hackers.nencrypted The passwords are openly visible in the database. It is unsafe for the people signing up to your site because you, and anybody with access to your database, know their passwords and you can use that to hack their accounts on other websites since many people use the same password in multiple places. To solve the password issue, you hash the passwords before storing them into your database using password_hash(). When searching for a user, you have to search by username first, pull out a hashed password and compare it to the data that was sent in the form using password_verify().
  2. The asynchronous nature of AJAX means that the code inside the done() and fail() methods only begin running long after the loop ended. Given your current code structure, the easiest way to solve it would be to keep track of whether it was sent already in a global variable. The following code will only work if the noticeSent variable is in the global scope. First define the global variable outside of the loop. var i; var noticeSent = false; for (i=0; i< feeid.length; i++) { When an AJAX response is returned, check the noticeSent variable and only send the notice if it hasn't already been sent: if (sendnotice == "Y" && !noticeSent) { noticeSent = true;
  3. I'm not asking you to look at the error console. Look at the network tab. It will have a whole lot of information in it whether or not the request failed. It has the HTTP method, the HTTP status code, the request headers, the request body, the response headers and the response body and it even provides information as to how long the request took to send, process and return from the server. Please show all the information that the network tab provides about the request. I've attached an image showing you what the network tab should look like in your browser:
  4. You can't put the console.log() in the success function, because a 500 is a failure. This is why you should monitor the AJAX request in the browser's developer tools.
  5. Is there anything in the AJAX response? If it's empty, the only thing left to do is keep stripping out parts of the PHP code until it stops returning 500.
  6. Ingolme

    Simple Transition

    You can use the CSS animation property for that. Unlike the transition property, the animation property does not need the element to have multiple states.
  7. What is the output when the code runs? If you're using AJAX to run the PHP, then you will be able to see the output in the response body of the request in the network tab of the browser development tools.
  8. There is no zoom feature in CSS, you have to create it yourself based on your understanding what zooming actually is. What does it mean to "zoom in" or "zoom out" on something? When you zoom in, what you actually do is make the object larger. In the same way, when you zoom out you are making the object smaller. This means that to make something "zoom" all you have to do is change its size. In CSS use can use the transform property to change the size of an object, you can also use the width and height properties. All of these properties can be used with CSS animation.
  9. What happens when you run the query? Do you get zero rows or is there an error occurring? My first guess is that there are no rows with workDate = '2017-12-05' To begin debugging this, make sure that PHP is catching the errors and printing them, then check the database for yourself to see if there are actually rows that match your search criteria.
  10. I am not going to angrily reply to people telling them that this is the wrong place, because it is not the wrong place. The fact that the staff stopped coming to the forums doesn't mean the suggestions forum isn't a place to put suggestions. When somebody comes here with a suggestion I will kindly inform them that the staff rarely visits the forum and I will point them to a place where their feedback is more likely to be heard.
  11. Step 1 is complete. We have verified that clicking the button does not fire the form submit event. Now we have to find out why. Keeping the code the same as in my previous post, verify that you are using <input type="submit"> and not <input type="button">. If you're using "button" then change it to "submit" and test again. If that was not the issue, the next step is to make sure that you have no form validation attributes. Attributes like "required" will prevent the form from submitting. If the issue is still occurring after that then reply here with your form's HTML structure and the small block of code that handles the form's events and we can move on from there.
  12. You have to use a programming language to loop through database records and generate options. HTML is completely unaware of what happens on the server.
  13. This forum's subtitle is "How can we improve W3Schools.com" The suggestions forum is specifically for feedback about the website.
  14. The click event is what's causing everything to stop working. It's the reason that your code works in one situation and not the other. If you're not going to listen to me I can't help you any further. Regardless of what the browser does, take my advice and remove the click event. If it is still not working after that then we can begin searching for the real cause of the problem. Delete this block of code and do not add it back under any circumstances: $('.SearchButton').on('click', function() { event.preventDefault(); findAndDisplay(); }); Start off with this code and nothing else: (function() { $('#qa_searchform').on('submit', function(event) { event.preventDefault(); findAndDisplay(); }); function findAndDisplay() { var search_qa_input = $("input#qa_input").val(); alert(search_qa_input); } })(); If this does not work, then we need to simplify even further. Do not add any code, continue removing code until it is too simple to fail. Once we reach that point, we can start adding things back in one by one.
  15. I told you that you don't need a click event. The submit event will automatically take click events from all the buttons in the form. The biggest problem here is that you keep adding the click event back. The click event must be eliminated, destroyed, nullified.
  16. Forget the AJAX call. Let's start off trying to guarantee that the form behaves the same whether you use a keyboard or mouse input to submit it. Put an alert() statement in the event handler and verify that you're getting the same behavior for both actions. $('#qa_searchform').on('submit', function(event) { event.preventDefault(); var search_qa_input = $("input#qa_input").val(); alert(search_qa_input); });
  17. The click event is bypassing your form submission event and reloading the page. I said it before, do not use any click events or any keyboard events. The only event listener you need is one single submit event listener. This is all you need: $('#qa_searchform').on('submit', function(event) { event.preventDefault(); var dataString = 'search_input=' + $("#qa_input").val(); $.ajax({***}); }); As long as you don't have any other code on the page that is interfering with it, this should work for both mouse and keyboard events. If that fails to work, you may have issues with the AJAX block of code.
  18. It looks like you're not running the code on a server that supports PHP.
  19. In order to keep information it has to be stored on the server. Usually it is kept in a database. You will need to learn a server-side programming language such as PHP and you'll have to learn how to use databases. W3Schools has a PHP tutorial and a MySQL tutorial. MySQL is the language used to interact with the database.
  20. You would need a mousemove event on the <body> element. Using that event, you would have to find the coordinates of the mouse relative to the page using the pageX and pageY event properties. Here's a quick example: document.body.addEventListener("mousemove", checkMousePosition, false); function checkMousePosition(e) { console.log(e.pageX, e.pageY); } If an element is a direct child of the body, you can set its position to absolute using CSS and its top and left properties will be relative to the page. Then you can use the mouse event to set the element's top and left properties: // You should store a reference to the element that will follow the mouse into the "element" variable element.style.top = e.pageX + "px"; element.style.left = e.pageY + "px";
  21. The requirements of your project are not clearly defined. You should not be asking questions like "How do I simulate a click using a key event?". Your end goal is not to click a button, it's to perform the action that happens when the button is clicked. What is that action? I don't know, you haven't made it clear, but knowing exactly what that action is is the most important factor in solving the problem. For now, I'll call the action "X". You have a form with a button and a text field. When the button is clicked, the form gets submitted. When somebody presses Enter in the text field, the form also gets submitted. Therefore we can perform action X during the submit event of the form. Do not use the click event. Do not use the keyup event. Only use the submit event. $("REFERENCE TO FORM").on("submit", function(e){ // Stop the form from reloading the page e.preventDefault(); // Do action "X" here: performActionX(); }); In order to keep the code readable, I highly advise against using anonymous functions. It's mixing function declarations with your program logic. Give your functions names, then use those functions as arguments in your jQuery calls. Applying this principle to the code above yields this, which might appear longer at first, but when the code logic is complicated it is much easier to see what's going on when the function declarations are out of the way as long as the functions have meaningful names. /* Code logic goes here */ $("REFERENCE TO FORM").on("submit", formSubmissionHandler); /* Function declarations go here */ function formSubmissionHandler(e) { // Stop the form from reloading the page e.preventDefault(); // Do action "X" here: performActionX(); }
  22. Most browsers will show the developer tools by pressing F12 on the keyboard. If not, you'll have to search the menus and options of the browser. Usually you can also open developer tools by right clicking on a page and selecting "Inspect Element" from the context menu.
  23. You can access the server's filesystem using a server-side programming language like PHP. If you want to access files on the user's computer you'll have to create a desktop program in a language like C++ or Java and ask the user to download and run it.
  24. No, you do not need a keyup listener. Pressing Enter on a form field automatically calls the forms submit method. The "submit" event is the one you should be listening for, not the keyup event.
  25. That's just a comment, it doesn't do anything. The comment is there to tell people what the code is doing. What does it even mean for one step to have two tabs? I cannot make sense of that.
×
×
  • Create New...