How to do an HTML select form where the selected option update a JSON value?
I currently have one HTML+JS webpage where I hard code the starting
condition (the West, North, East, South geographic coordinate of a
country) :
var WNES = { "W": 67.0, "N":37.5, "E": 99.0, "S": 5.0, "item":"India" };
I however just datamined data for ~180 countries, so I also have :
var WSEN_list = [
{"W":60.504050405040545;"S":29.306134923492337;"E":75.1575157515752;"N":38.47551472547255;"item":"Afghanistan"},
{"W":11.611161116111646;"S":-17.94743030603061;"E":24.068406840684105;"N":-4.453854347434742;"item":"Angola"},
{"W":19.279927992799315;"S":39.62168720072006;"E":21.00810081008106;"N":42.67814713471347;"item":"Albania"},
{...}
];
I want my end-user to pick a country using a html <select> element :
<form>
Select your country:
<select id="mySelect">
<option>Afghanistan</option>
<option>Albania</option>
<option>Angola</option>
</select>
</form>
then, to store the user's selected item value (by exemple "Angola"), and
state :
var WNES =
{"W":11.611161116111646;"S":-17.94743030603061;"E":24.068406840684105;"N":-4.453854347434742;"item":"Angola"};
How to do a such select button and system which update my WNES from the
WSEN_list ?
No comments:
Post a Comment