来自javascript问题的asp下拉列表动态值 [英] asp dropdownlist dynamic value from javascript issue

查看:33
本文介绍了来自javascript问题的asp下拉列表动态值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含 5 个项目的下拉列表.最后一项的值为其他".通过选择其他"出现带有输入的弹出窗口.这个输入的值我通过 javascript 设置为这个项目.所以值变成了插入的文本.当我提交表单时,它不适用于这个动态值,但选择的其他项目有效.有任何想法吗?非常感谢!

I have a dropdownlist with 5 items. Value of last item is "other". By choosing "other" appears popup with input. The value of this input i set to this item by javascript. So value becoms inserted text. When i submitting the form, it doesn't work with this dynamic value, but other items of select works. Any ideas? Thanks very much!

推荐答案

与其将此值设置为下拉列表项值,不如使用隐藏字段

Rather than set this value as droupdown list item value, you can use hiden field

<input type="hidden" id="hiddenField" runat="server" />

使用 JavaScript 设置值如下

set value using JavaScript as below

document.getElementById ("hiddenField").value = "inputValue";

hiddenField 值可以从下面的代码访问

hiddenField value can access from code behind as below

string inputValue = hiddenField.Value;

这篇关于来自javascript问题的asp下拉列表动态值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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