Click here to Skip to main content
15,881,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have created a json file with some data like

[
{"empid":2307535, "empname":"shekhar"},
{"empid":2307536, "empname":"smith"},
{"empid":2307537, "empname":"john"},
{"empid":2307544, "empname":"james"}
]

for this , whenever I write empid then I should get empname as well as validation also like
if max-length<7 || min-length>5 == error
as well as I need to check this empid means how to check whether entered empid is corect or not.


Please reply asap.

thanks.
Posted
Comments
Member 11619095 19-Apr-15 3:17am    
I am not using jquery.

1 solution

If you are using JQuery, you can do a loop
PHP
$.each(json, function(i, v) {
     if (v.empid == mySearchString) {
         //Do stuff
     }
 });
 
Share this answer
 
Comments
Member 11619095 19-Apr-15 3:30am    
but I am not using jquery.
Instead of jquery can you provide solution in java script or angularjs ?
Abhinav S 19-Apr-15 3:46am    
http://mattsnider.com/how-to-efficiently-search-a-json-array/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900