无法从客户端添加列表框中的值。 [英] Cant add values in listbox from client side.

查看:72
本文介绍了无法从客户端添加列表框中的值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在客户端(javascript和jquery)的列表框中添加值。



我尝试过:



我试过了js和jq,但都没有用,

我在JQ的代码

How to add values in list box from client (javascript and jquery).

What I have tried:

I tried both js and jq , but both not working,
my code in JQ

var value = 'aravind';
var listBox = $("lstProfLstS1");
var option = $("<option />").val(value).html(value);
listBox.append(option);
return false;



我在JS中的代码


my code in JS

var Val1='aravind';
var opt1 = document.createElement("option");
opt1.innerHTML = Val1.replace(/ /g, "\xA0");
opt1.value = Val1;
document.getElementById("lstProfLstS1").options.add(opt1);





问候,

Aravind



Regards,
Aravind

推荐答案

lstProfLstS1);
var option =
("lstProfLstS1"); var option =


< option />\").val(value).html(value);
listBox.append(option);
return false ;
("<option />").val(value).html(value); listBox.append(option); return false;



我在JS中的代码


my code in JS

var Val1='aravind';
var opt1 = document.createElement("option");
opt1.innerHTML = Val1.replace(/ /g, "\xA0");
opt1.value = Val1;
document.getElementById("lstProfLstS1").options.add(opt1);





问候,

Aravind



Regards,
Aravind


现在我们知道这是一个ASP控件,请参阅Karthik的评论你将无法在服务器端获得客户端增值(回发后)



但是,如果你想访问后面代码中的项目,那么使用隐藏字段来捕获客户端添加的项目。然后你可以查询隐藏的现场服务器端。



编辑 - 我发现这个工作示例 [ ^ ]
Now we know this is an ASP control, see Karthik's comment "you won't be able to get the client side added values in the server side (Post back)

However, if you want to access the items in the code behind then use a hidden field to capture the items that are added client side. You can then query that hidden field server side.

Edit - I've found this worked example[^]


这篇关于无法从客户端添加列表框中的值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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