如何将选定的值转换为字符串? [英] how to get the selected value into a string?

查看:60
本文介绍了如何将选定的值转换为字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的ASP代码

Here is my ASP code

<select id="Manufacturer" name="Manufacturer" <asp:Literal ID='litManfDis' runat='server' />
                  Manufacturer:  <option>SELECT MANUFACTURER</option>
                    <asp:Literal ID="litManf" runat="server" />
                </select>



以下是我填写选择选项的方法。


Here is how I fill my select options.

Dim strManaufacturer As String = Utilities.IsNull(Request.Form("Manufacturer"))




ds = dbnet.Manufacturers("select distinct I001001 from TESTDATA.VININDEX")
     For Each dr As DataRow In ds.Tables(0).Rows
       litManf.Text &= String.Format("<option{0}>{1}</option>", IIf(dr("I001001").ToString().Trim().Equals(strManaufacturer, StringComparison.InvariantCultureIgnoreCase), " selected=selected", String.Empty), System.Web.HttpUtility.HtmlEncode(dr("I001001").ToString().Trim()))
     Next



但我不知道知道如何将所选值转换为字符串。

任何人都可以帮我这个吗?


But I do not know how to get the selected value into a string.
Can anyone help me with this?

推荐答案

我建​​议使用javascript / jquery使用所选事件上的选定值更新HTML中的隐藏字段,然后在服务器端使用它。

在javascript中你可以像这样使用

I would suggest to use javascript/jquery to update a hidden field in your HTML with the selected value on selected event then use it in your server side.
In javascript you can use like this
for (var i = 0; i  < document.getElementById("Manufacturer").options.length; i++) {
       if(select.options[i].selected ) {


这篇关于如何将选定的值转换为字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆