我需要创建html5
- 2 个下拉菜单和 1 个输入框,然后创建一个由用户选择的 3 个选项创建的链接。我无法通过用户输入和选择将链接放在一起
html
<select id="text1" onchange="setupLink();">
<option selected value="base">Please Select Your Town</option>
<option value="witbank">Witbank</option>
<option value="middelburg">Middelburg</option>
</select>
<select id="text2" onchange="setupLink();">
<option selected value="base">Please Select Your Agency</option>
<option value="huizemark">Huizemark</option>
<option value="seef">Seef</option>
</select>
Here is a link : <a href="" id=lnk>nothing here yet</a> <br>
脚本
<script type="text/javascript">
function getUrl() {
var part1 = document.getElementById("text1").value;
var part2 = document.getElementById("text2").value;
}
function changeText2(){
var userInput = document.getElementById('userInput').value;
var lnk = document.getElementById('lnk');
lnk.href = "http://in"+text1+text2+userInput;
lnk.innerHTML = lnk.href;
}
</script>
我得到这个:http://in[object HTMLSelectElement].com/[object HTMLSelectElement]/test 而不是这个:http: //inwitbank.com/huizemark/test