<ul class="sub-menu">
<li><a href="">Cycle Store & Services</a></li>
</ul>
function Demo(anchor) {
var value = anchor.getAttribute('value')
var locName=document.getElementById("locName").value;
if(value.includes('&')){
value = value.replace("&", "%26");
}
if(locName==""){
alert("Please Select your Location");
}
else
{
window.location = "http://www.citycontact.in/SpecificCategory.php?id="+value+"&locName="+locName;
}
}
我有这样的代码,我需要使用“ http://www.citycontact.in/SpecificCategory.php?id=” + value +“&locName =” + locName; href中的值
答案 0 :(得分:1)
请尝试以下代码。脚本标记任务和变量值缺少“;”分号
<ul class="sub-menu">
<li><a href="">Cycle Store & Services</a></li>
</ul>
<script>
function Demo(anchor) {
var value = anchor.getAttribute('value');
var locName=document.getElementById("locName").value;
if(value.includes('&')){
value = value.replace("&", "%26");
}
if(locName==""){
alert("Please Select your Location");
}
else
{
window.location = "http://www.citycontact.in/SpecificCategory.php?id="+value+"&locName="+locName;
}
}
</script>