<a href="javascript:void(0)" onclick="goto()" /> function goto(){ var ddl = document.getElementById("ddl"); var id = ddl.options[ddl.selectedIndex].text; //var href = document.getElementById("abc").href; //href=href+id; //document.getElementById("abc").href=href; var href="url?a="+id; window.location = href; }
那你每次改变ddl值后 var prehref = "Http://...url?id="; var idvalue = document.getElementById("ddl").value; document.getElementById("abc").href='"prehref""+idvalue+"';试试,不知道对不对。
var href = document.getElementById("abc").href.split('?')[0]+'a=';
<script> function go(){ var ddl = document.getElementById("ddl"); var id = ddl.options[ddl.selectedIndex].text; var url="你的url的前缀"; window.location.href=url+id; } </script> <a onclick="go()">
function goto(){
var ddl = document.getElementById("ddl");
var id = ddl.options[ddl.selectedIndex].text;
//var href = document.getElementById("abc").href;
//href=href+id;
//document.getElementById("abc").href=href;
var href="url?a="+id;
window.location = href;
}
var prehref = "Http://...url?id=";
var idvalue = document.getElementById("ddl").value;
document.getElementById("abc").href='"prehref""+idvalue+"';试试,不知道对不对。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title> <script language="javascript">
function Go()
{
document.location.href = "your_address?your_parameter=" + document.getElementById("mySelect").value;
}
</script></head>
<body>
<form id="form1" runat="server">
<div>
<select id="mySelect">
<option value="1">Go home</option>
<option value="2">Call girl friend</option>
</select>
</div>
<div>
<input type="button" value="Click me" onclick="Go();" />
</div>
</form>
</body>
</html>
function go(){
var ddl = document.getElementById("ddl");
var id = ddl.options[ddl.selectedIndex].text;
var url="你的url的前缀";
window.location.href=url+id;
}
</script>
<a onclick="go()">