-2

So the HTML is

<select name="city">
  <option value="Mysuru">Mysuru</option>
  <option value="Bagalkote">BagalkoteBagalkote</option>
</select>

in java script I have to parse a JSON file using the above drop-down value.

the js code is:

app.post("/", function(req, res) {
var city= req.body.city;

So in the above code I took the data from html post

now I have a json data which is parsed:

var jdata=JSON.parse(body);

So now I need the particular data from the jdata

var activecases=jdata.Karnataka.districtData.city.active;

here city is a variable which contains the cityname but now doesn't work it shows error that city is not defined.... but if i put Mysuru instead of city it works... but I need to put city there because it will be varying every time as the person chooses different city in HTML...

Pls someone help me out..

the json file is https://api.covid19india.org/state_district_wise.json

1 Answers1

-1

Try select tag with name attribute:

<select name="Karnataka[districtData][city][active]">
</select>
Lee
  • 418
  • 2
  • 8