问题描述
我正在使用雅虎解决方案制作一个购物中心网站。我有多个项目选项,有些项目的价格取决于选项。
I'm making a shopping mall website using a Yahoo solution. I have multiple options for items and some items have different price dependent on the options.
雅虎不支持多个价格选项,因此我尝试找到一个解决方案这个问题。我的一个想法是制作多个页面并根据选项重定向页面。例如,如果客户选择了型号A,则该页面将保留在显示$ 1000的页面A中。如果客户选择了模型B,页面将重定向到显示$ 500的页面B.
Yahoo doesn't support multiple price options, and therefore I try to find a solution for this problem. One of my ideas is to make multiple pages and redirect the page dependent on options. For example, if a customer chose model A, the page will stay in the page A which displays $1000. If a customer chose model B, the page will redirect to the page B which displays $500.
我已经使用JavaScript制作了动态选项,但我想将其修改为重定向页面。以下是我的页面链接:
I have already made dynamic options with JavaScript, but I want to modify it to redirect a page. Here is the link of my page:
在页面中,中间有选项。如果顾客选择了他/她的手,它会显示选项,#4 Thru AW,Lob Wedge和Sand Wedge。如果客户选择Lob Wedge或Sand Wedge,页面必须重定向到具有不同价格的页面。
In the page, there are options in the middle. If a customer chose his/her hand, it shows options, "#4 Thru AW," "Lob Wedge," and "Sand Wedge." If a customer chose either "Lob Wedge" or "Sand Wedge', the page has to redirect to a page which has a different price.
PS:
我正在使用JavaScript生成依赖于前一个选项的选项。代码是:
I'm using JavaScript to generate options dependent on the previous option. The code is:
<script type="text/javascript" language="javascript">
<!--
document.write('<select name="Iron(s)" onChange="javascript: listboxchange (this.options[this.selectedIndex].value);"><option value="">Select Iron(s)</option></select>')
-->
</script>
推荐答案
使用:
window.location = "http://my.url.here";
这里有一些使用jQuery做你想做的快速脏代码。强烈推荐使用jQuery。它会让事情变得更加轻松,特别是因为你不熟悉JavaScript。
Here's some quick-n-dirty code that uses jQuery to do what you want. I highly recommend using jQuery. It'll make things a lot more easier for you, especially since you're new to JavaScript.
<select id = "pricingOptions" name = "pricingOptions">
<option value = "500">Option A</option>
<option value = "1000">Option B</option>
</select>
<script type = "text/javascript" language = "javascript">
jQuery(document).ready(function() {
jQuery("#pricingOptions").change(function() {
if(this.options[this.selectedIndex].value == "500") {
window.location = "http://example.com/foo.php?option=500";
}
});
});
</script>
这篇关于如何使用JavaScript重定向页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!