Loading...
Copy code
Close
Permalink
Close
Please tell us why you want to mark the subject as inappropriate.
(Maximum 200 characters)
Report Inappropriate
Cancel
Private Message
From :
guest
To :
Subject :
Content :
Type the characters you see in the picture below.
Send
Cancel
From :
guest
To :
Subject :
Content :
Type the characters you see in the picture below.
Send
Update
Cancel
Feedback
Email ID
Subject :
Comments :
Send
Cancel
Private Message
Type the characters you see in the picture below.
Type the characters you see in the picture below.
Attach files
Desktop
Google Docs
Each Attachment size should not exceed 1.0 MB.
Max no of attachments : 3
Loading User Profile...
guest
Response title
This is preview!
Attachments
Publish
Back to edit
Cancel
(
)
Sign In
New to this Portal? Click here to
Sign up
You can also use the below options to login
Login with Facebook
Login with Google
Login with Yahoo
jQuery
Plugins
UI
Meetups
Forum
Blog
About
Donate
All Forums
Recent Posts
Log In
Search
jQuery
Search
jQuery Forum
Move this topic
Forum :
Getting Started
Using jQuery
Using jQuery Plugins
Using jQuery UI
Developing jQuery Core
Developing jQuery Plugins
Developing jQuery UI
QUnit and Testing
About the jQuery Forum
jQuery Conferences
jQuery Mobile
Developing jQuery Mobile
Sub forum :
Move this topic
Cancel
Using jQuery
headshot9..
How to custom data text value in autocomplete ?
in
Using jQuery
•
8 years ago
Hello guys.
I have try show data and get value using autocomplete jquery. Textbox will show data choose and label will get value .But it's error
Uncaught TypeError: Cannot read property 'DEPARTMENT_ID' of undefined
.
This is data JSON when i see console.log
Object {d: "[{"DEPARTMENT_ID":"D00000000001","DEPARTMENT_NAME"…"2015-05-05T00:00:00","EDIT_BY":"","FLAG":false}]"}
d: "[{"DEPARTMENT_ID":"D00000000001","DEPARTMENT_NAME":"HR","DEPARTMENT_DES":"HR","EDIT_DATE":"2015-05-05T00:00:00","EDIT_BY":"","FLAG":false},
{"DEPARTMENT_ID":"D00000000002","DEPARTMENT_NAME":"ACCOUNT","DEPARTMENT_DES":"ACCOUNT","EDIT_DATE":"2015-05-05T00:00:00","EDIT_BY":"","FLAG":false}]"
__proto__: Object
and this is function
function load_text() {
$.ajax(
{
type: "POST",
url: "../BUS/WebService.asmx/LIST_DEPARTMENT",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
var valuetextbox = [];
$.each($.parseJSON(data.d), function (idx, obj) {
valuetextbox.push(obj.DEPARTMENT_NAME);
});
$('#txt_textbox').autocomplete({
source: valuetextbox,
select: function (event, ui) {
$("#label_value").val(ui.item.obj.DEPARTMENT_ID);
}
});
},
error: function (data) {
alert("Error load");
}
});
}
1
Replies(9)
jakecigar
Re: How to custom data text value in autocomplete ?
8 years ago
Object {d: "[{"DEPARTMENT_ID":"D00000000001","DEPARTMENT_NAME"…"2015-05-05T00:00:00","EDIT_BY":"","FLAG":false}]"}
what’s that quote doing there after the first colon? You encoded your JSON wrong.
JΛ̊KE
headshot9..
Re: Re: How to custom data text value in autocomplete ?
8 years ago
No , When you use console.log , you'll see as .Please read as clearly.Thank sir,
Leave a comment on jakecigar's reply
jakecigar
Re: How to custom data text value in autocomplete ?
8 years ago
$("#label_value").val(ui.item.obj.DEPARTMENT_ID);
That
’s where the problem is.
There is no
ui.item.obj.DEPARTMENT_ID.
JΛ̊KE
headshot9..
Re: Re: How to custom data text value in autocomplete ?
8 years ago
Yes, that's right. And you can tell me or give me some advice how to fix it .Thank sir so much.It's can show data autocomplete , and i want get value DEPARTMENT_ID follow it.
Leave a comment on jakecigar's reply
jakecigar
Re: How to custom data text value in autocomplete ?
8 years ago
I think it would be
ui.item.
Normally I would push an object, not a string. Then I would use
ui.item.value.
JΛ̊KE
headshot9..
Re: Re: How to custom data text value in autocomplete ?
8 years ago
Did you try it . I try but it's not work .Thank men.
Leave a comment on jakecigar's reply
jakecigar
Re: How to custom data text value in autocomplete ?
8 years ago
Did you share a link that I missed? Did you add a console.log to see what your variables are?
JΛ̊KE
headshot9..
Re: Re: How to custom data text value in autocomplete ?
8 years ago
Dear jakecigar .I test in localhost , as anything above , i've description clearly. Plz read it.
Thank you.
Leave a comment on jakecigar's reply
jakecigar
Re: How to custom data text value in autocomplete ?
8 years ago
I don’t want to attempt to recreate your problem. Put it on a server or use a more common example.
JΛ̊KE
Leave a comment on jakecigar's reply
Change topic type
Topic Type :
Discussions
Questions
Ideas
Problems
No of days :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Change topic type
Cancel
Link this topic
Provide the permalink of a topic that is related to this topic
Permalink
Save
Close
Reply to headshot9x9's question
Top
Reply
{"z52321725":[14737000006241548,14737000006241563,14737000006241599,14737000006238341,14737000006240843],"z2950240":[14737000006239665,14737000006239677,14737000006239743,14737000006239859,14737000006239921]}
Statistics
9
Replies
2912
Views
1
Followers
Tags
Cancel
textbox
jquery
json
webservice
label
Actions
Permalink