My website project includes taking data from the user in the form of two input fields. These fields are a starting location and a destination on a map.
First problem arises here; the user must click a button to submit the input fields instead of just hitting enter. Found solution here: I need help submitting a form. I do not want the page to refresh, and I do not know how to accomplish this
If the user then decides that they want to change either location, they first have to refresh the page and start over. This is where the second problem arises; most users (read: all users) don’t want to have to refresh just to change something small like this.
How can I get it so that enter will submit the data, and how can I make it so that the inputs can be changed without having to refresh?
This project uses Google Maps to map out the start location, destination, the route, as well as certain checkpoints.
If you would like to view the project as it is now, please visit: http://ec2-107-22-36-152.compute-1.amazonaws.com/ProjectAlpha/BOJEMI_Travels.html
I’ll answer what I can:
To capture the “enter” keypress, you would do something like this:
In terms of the issue with refreshing the directions, I’m now getting a JS error:
Looking at your code, you are using the following structure:
I don’t know if this will solve the problem or not, but you might try the following syntax for your “for loop”:
In the version you have, you are assuming that all indice names will be in order, when they may not be. In my version, i only gets set to actual indice names as the value for i. I don’t know if that will solve the problem as a whole, but it will certainly fix the JS error that I was getting at the time, and I have a hunch that will let the rest of your code execute gracefully.