我的网站项目包括以两个输入字段的形式从用户那里获取数据。这些字段是地图上的起始位置和目的地。
第一个问题出现在这里;用户必须单击按钮来提交输入字段,而不仅仅是按 Enter 键。 在这里找到解决方案:我需要帮助提交表单。我不想刷新页面,而且我不知道如何完成此操作
如果用户决定要更改任一位置,他们首先必须刷新页面并重新开始。这就是第二个问题出现的地方;大多数用户(阅读:所有用户)不希望仅仅为了更改这样的小内容而刷新。
如何获取它以便输入将提交数据,以及如何才能使输入可以更改而无需刷新?
该项目使用谷歌地图来绘制出发地点、目的地、路线以及某些检查站。
如果您想查看项目现在的样子,请访问:http://ec2-107-22-36-152.compute-1.amazonaws.com/ProjectAlpha/BOJEMI_Travels.html
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
发布评论
评论(1)
我会尽力回答:
要捕获“输入”按键,您需要执行以下操作:就
刷新方向的问题而言,我现在收到 JS 错误:
查看您的代码,您正在使用以下结构:
我不知道这是否能解决问题,但您可以为“for 循环”尝试以下语法:
在您拥有的版本中,您假设所有索引名称都按顺序排列,当他们可能不是的时候。在我的版本中,i 仅设置为实际索引名称作为 i 的值。我不知道这是否能解决整个问题,但它肯定会修复我当时遇到的 JS 错误,而且我有预感,这会让你的其余代码正常执行。
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.