How to pass variable to href in javascript?

前端 未结 5 1693
没有蜡笔的小新
没有蜡笔的小新 2021-01-04 09:24

How to pass this variable value here? Below code is not working. And all other discussions on Stackoverflow are unclear.



        
5条回答
  •  庸人自扰
    2021-01-04 09:48

    Try this:

    function check() {
        var dist = document.getElementById('value').value;
    
        if (dist) {
            window.location.href = "district.php?dist=" + dist;
        } else {
            alert('Oops.!!');
        }
    }
    

提交回复
热议问题