<script>
var user=
{
"userinfo":[
{
"username":"ana",
"loginpassword":"livi",
"adress":"karolbagh",
"phonenumber":876511649,
"userid":100
},
{
"username":"jenny",
"loginpassword":"jackson",
"adress":"newmarket",
"phonenumber":7651294624,
"userid":110
},
{
"username":"jamie",
"loginpassword":"jackson",
"adress":"hatibagan",
"phonenumber":7191210598,
"userid":420
},
],
"clothing":[
{
"productid":"1a1a",
"sellerid":1212,
"name":"ginghamshirt",
"colour":"pink",
"sizes":["m","l","s"]
},
{
"productid":"1212",
"sellerid":1222,
"name":"shirt",
"colour":"grey",
"sizes":["m","l","s"]
},
{
"productid":"1332",
"sellerid":1221,
"name":"skirt",
"colour":"black",
"sizes":["m","l","s"]
},
],
"orders":[{
"orderid":"1111",
"userid":100,
"productid":"1a1a",
"size":"m",
"name":"ginghamshirt",
"colour":"pink",
"adress":"karolbagh",
"phonenumber":876511649
},
{
"orderid":"1110",
"userid":420,
"productid":"1212",
"size":"l",
"name":"shirt",
"colour":"grey",
"adress":"hatibagan",
"phonenumber":7191210598
},
]
}
var search = function (anyname,anyuser)
{
console.log(anyuser.userinfo.length)
for(var i in anyuser.userinfo)
{
if(anyuser.userinfo[i].username == anyname)
{
alert(anyuser.userinfo[i].username)
alert(anyuser.userinfo[i].adress)
}
}
}
search(custname,user)
var custname = window.prompt('enter the name OF customer you want to know details about')
</script>
Would it work better if you did the search after getting the name?
2 Likes
it worked after following your suggestion thank you
1 Like
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.