如何让页面对主页上提供的信息做出反应?

时间:2022-12-12 01:51:04

My homepage consists of a form with drop-down options, specifically city names (i.e., New York, LA, Miami, etc...) When a user picks a city, he/she is redirected to another page, which is supposed to display deal results (call this the deal page).

我的主页包含一个带有下拉选项的表单,特别是城市名称(即纽约,洛杉矶,迈阿密等...)当用户选择一个城市时,他/她被重定向到另一个页面,这应该是显示交易结果(称之为交易页面)。

Basically, I am wondering how to get the deal page to display information based on the city picked on the homepage? I am using queries to retrieve results, but I want the queries to change based on the city picked so that the information of the deal page is relevant.

基本上,我想知道如何让交易页面显示基于主页上选择的城市的信息?我正在使用查询来检索结果,但我希望查询根据所选城市进行更改,以便交易页面的信息相关。

If the answer is too detailed, can someone point me to the specific topic that this relates to and maybe a website that provides answers?

如果答案太详细,有人可以指出我与此相关的特定主题,也许是一个提供答案的网站?

Thanks

2 个解决方案

#1


0  

For the dropdown, add an on Change listener that redirects to a different url. The url could be something like process.php?city=Maine

对于下拉列表,添加一个重定向到另一个URL的Change侦听器。网址可能类似于process.php?city =缅因州

To add an onchange listener

添加onchange侦听器

document.getElementById('citydropdown').addEventListener('change', myFunc, false);

To redirect in javascript:

要在javascript中重定向:

window.location = newUrl;

#2


0  

You have to use an onchange event in the select. Here is an example: http://lab.artlung.com/dropdown/ By the way: using onchange="window.open(url, '_self');" is like a redirect to an url. To get the value from the user selected option use: onchange="window.open(this.value, '_self');"

您必须在select中使用onchange事件。这是一个例子:http://lab.artlung.com/dropdown/顺便说一句:使用onchange =“window.open(url,'_ self');”就像重定向到网址。要从用户选择的选项中获取值,请使用:onchange =“window.open(this.value,'_ self');”

#1


0  

For the dropdown, add an on Change listener that redirects to a different url. The url could be something like process.php?city=Maine

对于下拉列表,添加一个重定向到另一个URL的Change侦听器。网址可能类似于process.php?city =缅因州

To add an onchange listener

添加onchange侦听器

document.getElementById('citydropdown').addEventListener('change', myFunc, false);

To redirect in javascript:

要在javascript中重定向:

window.location = newUrl;

#2


0  

You have to use an onchange event in the select. Here is an example: http://lab.artlung.com/dropdown/ By the way: using onchange="window.open(url, '_self');" is like a redirect to an url. To get the value from the user selected option use: onchange="window.open(this.value, '_self');"

您必须在select中使用onchange事件。这是一个例子:http://lab.artlung.com/dropdown/顺便说一句:使用onchange =“window.open(url,'_ self');”就像重定向到网址。要从用户选择的选项中获取值,请使用:onchange =“window.open(this.value,'_ self');”