Discuss / JavaScript / Exercise

Exercise

Topic source

FranzWH

#1 Created at ... [Delete] [Delete and Lock User]

Input:

json = {};
json.name=$('input[name=name]')[0].value;
json.email=$('input[name=email]')[0].value;
json.password=$('input[name=password]')[0].value;
json.gender=$('input[name=gender]')[0].checked?'m':'f';
json.city=$('select[name=city]')[0].value;
json=JSON.stringify(json,null,'   ');

Output:

{
   "name": "123",
   "email": "123@123.com",
   "password": "123",
   "gender": "f",
   "city": "XM"
}

  • 1

Reply