添加 else if 语句以使用 javascript 在 html 中提取页面
我们有一个由外部公司开发的新网站,但我们遇到了问题。我试图找出一段代码的逻辑,如果满足某些要求,该代码将拉出一个新页面。
首先,这是网站 http://www.winstonind.com/service
对于任何服务商在美国,它会调出谷歌地图和我们的服务商的位置,以获取下拉列表中的任何其他选项,但它不会执行任何操作。我想知道的是,如果选择了中国,它将转到我使用该地区的服务商列表创建的页面,您能帮我吗?我还不太了解 Javascript,而且由于该网站已经上线,所以我无法进行大量修改。
<script type="text/javascript">
$("#country").change(function(){
$(this).val()!='default'?$("#state").hide():$("#state").show();
});
var typeChoice;
$("#step1next").click(function(){
typeChoice = $(".mt:checked").val();
$(".step.1").removeClass('selected');
$(".step.2").addClass('selected');
$(".step.1 .sContent").slideUp();
$(".step.2 .sContent").slideDown();
});
$("#step2next").click(function(){
if(typeChoice == 'type1')
{
$("#mapResult").html('<p style="text-align:center; margin-bottom:5px;">For all service requests that are in-warranty please contact Winston Industries directly.</p><p style="text-align:center;">Toll free: 1-800-234-5286<br/>International: +1-502-495-5400</p>');
}else{
$("#mapResult").html('');
var zip='';
$("#state").val()==$("#state").attr('default')?zip='':zip=$("#state").val();
//to make distance dynamic, replace 50 with a dynamic value
$.post('service/getMap/'+zip+'/50',function(data){
$("#mapResult").html(data);
});
}
$(".step.2").removeClass('selected');
$(".step.3").addClass('selected');
$(".step.2 .sContent").slideUp();
$(".step.3 .sContent").slideDown();
});
$(".sContent").hide();
$(".selected .sContent").show();
</script>
We have a new website developed by a outside company that we are having issues with. I am trying to figure out the logic on a piece of code that would pull up a new page if some requirements are met.
First of all this is the site http://www.winstonind.com/service
For any servicer in the US it pulls up a Google map and the locations of our servicers for any other options in the drop-down it doesn't do anything. what I would like to know is how I would make is so if china is selected it would go to a page I created with the list of servicers from that region can you help me with this? I don't understand alot of Javascript yet and I cant tinker alot since the site is live.
<script type="text/javascript">
$("#country").change(function(){
$(this).val()!='default'?$("#state").hide():$("#state").show();
});
var typeChoice;
$("#step1next").click(function(){
typeChoice = $(".mt:checked").val();
$(".step.1").removeClass('selected');
$(".step.2").addClass('selected');
$(".step.1 .sContent").slideUp();
$(".step.2 .sContent").slideDown();
});
$("#step2next").click(function(){
if(typeChoice == 'type1')
{
$("#mapResult").html('<p style="text-align:center; margin-bottom:5px;">For all service requests that are in-warranty please contact Winston Industries directly.</p><p style="text-align:center;">Toll free: 1-800-234-5286<br/>International: +1-502-495-5400</p>');
}else{
$("#mapResult").html('');
var zip='';
$("#state").val()==$("#state").attr('default')?zip='':zip=$("#state").val();
//to make distance dynamic, replace 50 with a dynamic value
$.post('service/getMap/'+zip+'/50',function(data){
$("#mapResult").html(data);
});
}
$(".step.2").removeClass('selected');
$(".step.3").addClass('selected');
$(".step.2 .sContent").slideUp();
$(".step.3 .sContent").slideDown();
});
$(".sContent").hide();
$(".selected .sContent").show();
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在关闭之前添加以下内容并修改 url 以指向正确的目录和 url。
这就是您的选择框代码的样子:
您会注意到第一行中的“id”称为国家/地区。所以我们想要读取用户在国家/地区选择框中放置的值,可以是加拿大、中国、美国等...
Add the following before your closing and modify the url to point to the correct directory and url.
This is what your select box code looks like:
You will notice that the "id" in the first line is called country. so we want to read the value that the user has placed in the select box of country which could be canada, china, USA, etc...
我认为这有点像你想要的:
i think this is somewhat what you wanted: