且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从下拉菜单中选择并重新加载页面

更新时间:2021-07-29 21:53:42

例如,我认为form可能会更好

I think form may be better, for example

<form id="myform" method="post">
<select name = 'peer-id' style = 'position: relative' onchange="change()">
    <option value="1">12</option>
    <option value="2">15</option>
    <option value="3">16</option>
    <option value="4">18</option>
</select>
</form>

<script>
function change(){
    document.getElementById("myform").submit();
}
</script>

在上面的代码中,每当更改select的值时,它将发布到后端,然后根据发布的值,您可以想要,要获取php中的peer-id,您可以使用以下代码

In the above code, whenever you change the value of select, it will post to the backend, then according to the posted value, you can do want you want, to get the peer-id in php, you can use the following code

$peer-id = $_POST['peer-id'];

希望有帮助!