我有以下代码,效果很好:
<script>
function process()
{
var url=document.getElementById("domain").value + document.getElementById("tld").value;
location.href=url;
return false;
}
</script>
<form onSubmit="return process();">
URL: <input type="text" name="domain" id="domain"> <input type="text" name="tld" id="tld"> <input type="submit" value="go">
</form>
它给了我www.domain.com/google.com('google'是域名,'。com'是tld)
但是,我想用'tld'输入替换选择菜单。我试过这个:
<script>
function process()
{
var url=document.getElementById("domain").value + document.getElementById("tld").value;
location.href=url;
return false;
}
</script>
<form onSubmit="return process();">
URL: <input type="text" name="domain" id="domain"> <select name="tld"><option value=".com">.com</option></select><input type="submit" value="go">
</form>
答案 0 :(得分:0)
你没有给select标签一个id。
select name="tld" id="tld">