【发布时间】:2015-02-16 11:00:56
【问题描述】:
我们有这样的 JSON
"[{\"UserID\":1,\"Name\":\"demo\"},{\"UserID\":4,\"Name\":\"ekova\"},{\"UserID\":2,\"Name\":\"Himansu-it\"},{\"UserID\":3,\"Name\":\"Himansu-it Services\"}]"
我们需要在下拉列表中显示用户名,如果我在下拉列表中选择名称,我们需要获取用户 ID。如果我们选择 ekvoa,我们需要获取用户 ID 4
我们这样显示用户名下拉
function selectitems(){
var getCustomerIDs = jQuery.parseJSON( customerID );
$(getCustomerIDs).each(function() {
console.log(this.UserID);
console.log(this.Name);
$('#date').append('<option>'+this.Name+'</option>');
});
}
我们需要像这样发布 UserID
$.ajax({
url:'http://www.himansuit.com/DemoSalesApp/MyService.svc/GetCurrentGeoLocationsByUserID/'+userID,
dataType: 'jsonp',
type:'get',
cache:false,
timeout: 10000,
error: function(x, t, m) {
if(t==="timeout") {
debugger;
$('#alertmessage').empty();
alert("NO Internet Connection");
// withOutNetConnection();
} else {
//alert(t);
}},
success:function(data) {
debugger;
GetAllElementsjson=data;
elements();
}
});
请指导我。
【问题讨论】:
-
有写选择框改变事件代码吗?
-
你的下拉菜单在哪里
-
@Sandeeproop 按钮操作
标签: javascript jquery json cordova drop-down-menu