我創建了一個條件表單,點擊提交後需要指向特定的產品頁面。這可能與這個代碼有關嗎?我無法弄清楚如何將數組值鏈接到URL變量。Javascript - 根據動態填充的下拉菜單轉到url
a=new Array("V1-1: 1/4-4 900-4500#", "V1-1 Light-Weight Compact Solution", "V1-2: 1/2-36 150-600#","V1-3: 1/2-2, 150-600#","V1-4: 4-36 900-4500#");
b=new Array('NexTech® R Series Valves','NexTech® E Series Valves','TrunTech® Valves', 'PulseJet Valves');
c=new Array('Coking Isolation Valves','Coking Switch Valves');
d=new Array('Three-Way Valves','Four-Way Valves');
e=new Array('IsoTech®');
f=new Array('Xactrol® Mark I Valves', 'Xactrol® Mark II Valves', 'Xactrol® Mark III Valves');
g=new Array('PulseJet Valves','Ecopack®');
h=new Array('AbrasoCheck® Slurry Check Valves', 'AbrasoTech® Slurry Ball Valves');
i=new Array('Electronic Relief Valves');
j=new Array('ValvXpress® Automated Valve Packages');
k=new Array('Acid Injection Valves');
l=new Array('Double Block-and-Bleed Valves');
m=new Array('Turbine Bypass System');
n=new Array('Check Valves');
o=new Array('ValvXpress®','EcoPack®','ValvPerformance Testing®','Slurry Valves','Acid Injection Valves','Double Block-and-bleed Valves','Rhinoite® Hardfacing','Switch Valves','HVOF RiTech®','Cryogenic Valves');
populateSelect();
$(function() {
$('#cat').change(function(){
populateSelect();
});
});
function populateSelect(){
cat=$('#cat').val();
$('#item').html('');
if(cat=='a'){
a.forEach(function(t) {
$('#item').append('<option>'+t+'</option>');
});
}
if(cat=='b'){
b.forEach(function(t) {
$('#item').append('<option>'+t+'</option>');
});
}
if(cat=='c'){
c.forEach(function(t) {
$('#item').append('<option>'+t+'</option>');
});
}
if(cat=='d'){
d.forEach(function(t) {
$('#item').append('<option>'+t+'</option>');
});
}
if(cat=='e'){
e.forEach(function(t) {
$('#item').append('<option>'+t+'</option>');
});
}
if(cat=='f'){
f.forEach(function(t) {
$('#item').append('<option>'+t+'</option>');
});
}
if(cat=='g'){
g.forEach(function(t) {
$('#item').append('<option>'+t+'</option>');
});
}
if(cat=='h'){
h.forEach(function(t) {
$('#item').append('<option>'+t+'</option>');
});
}
if(cat=='i'){
i.forEach(function(t) {
$('#item').append('<option>'+t+'</option>');
});
}
if(cat=='j'){
j.forEach(function(t) {
$('#item').append('<option>'+t+'</option>');
});
}
if(cat=='k'){
k.forEach(function(t) {
$('#item').append('<option>'+t+'</option>');
});
}
if(cat=='l'){
l.forEach(function(t) {
$('#item').append('<option>'+t+'</option>');
});
}
if(cat=='m'){
m.forEach(function(t) {
$('#item').append('<option>'+t+'</option>');
});
}
if(cat=='n'){
n.forEach(function(t) {
$('#item').append('<option>'+t+'</option>');
});
}
if(cat=='o'){
o.forEach(function(t) {
$('#item').append('<option>'+t+'</option>');
});
}
}
是否有每個數組中的每個條目的url? – Gavin
使用此代碼?不,因爲此代碼沒有任何內容指示每個數組項的URL應該是什麼。 –
@MikeMcCaughan我認爲這是關於「......弄清楚如何將數組值鏈接到一個URL變量......」的問題...... – cske