Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使一个选择选项更改另一个选择中的选项_Javascript_Asp.net_Ajax_Vb.net - Fatal编程技术网

Javascript 如何使一个选择选项更改另一个选择中的选项

Javascript 如何使一个选择选项更改另一个选择中的选项,javascript,asp.net,ajax,vb.net,Javascript,Asp.net,Ajax,Vb.net,我有两个下拉列表。SelCurrentManuf和selCurrentModel。我希望selCurrentModel中的选项根据selCurrentManuf中选择的选项进行更改。我该怎么做 <asp:DropDownList runat="server" ID="selCurrentManuf"></asp:DropDownList> <asp:DropDownList runat="server" ID="selCurrentModel"></as

我有两个下拉列表。SelCurrentManuf和selCurrentModel。我希望selCurrentModel中的选项根据selCurrentManuf中选择的选项进行更改。我该怎么做

<asp:DropDownList runat="server" ID="selCurrentManuf"></asp:DropDownList>
<asp:DropDownList runat="server" ID="selCurrentModel"></asp:DropDownList>
但它只填充第一个选定的manuf,并且在之后不会更改

Private Sub selCurrentManuf_SelectedIndexChanged(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles selCurrentManuf.SelectedIndexChanged

       PopulateCurrentModel()
End Sub

selCurrentManuf.Text
更改为
selCurrentManuf.SelectedItem.Value


请注意:您存在SQL注入安全漏洞。请搜索SQL注入和修复。

这就是所需的全部!autopostback=“true”

这个问题与.net、ajax、vb.net、vb、asp等无关,它只涉及javascript。您打算做什么?或者?啊,是的,这正是我想做的,但这个例子是c#,我想我正在使用vb@Uku这听起来像是我个人会使用AJAX解决的问题。我在想,当选择selCurrentMauf时,我还知道如何刷新selCurrentModel下拉列表吗?您现有的代码已经
selCurrentManuf
,如果没有更多的代码,我无法解释为什么会出现此错误。打字错误你换了什么吗?对不起,我换了一页。但是,即使在我展示的页面上,当一个用户下拉框并更改模型时,另一个下拉框的值不会更改,它也不会再次运行该函数。您是否已连接到on change事件?on change事件应该调用上面的代码。与my on change无关,my on change看起来正确吗?在循环之前添加一个
selCurrentModel.Items.Clear()
Private Sub selCurrentManuf_SelectedIndexChanged(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles selCurrentManuf.SelectedIndexChanged

       PopulateCurrentModel()
End Sub