user15966041
user15966041

Reputation: 11

Possible way to change the values inside an variable when a click event is called?

I have a variable called "places ". Is there any way i can pass my own variable values into places when an event listener is clicked. My concept is shown below. Pardon me if this is not possible. Thanks a lot.

var places = {
  'type': 'FeatureCollection',
  'features': [
    {
      'type': 'Feature',
      'properties': {
        'name': 'Trailer 1',  // change this value from Trailer 1 to Trailer 2
        'title': 'Trailer 1',
      },
      'geometry': {
        'type': 'Point',
        'coordinates': [lg13, lt13] // change this value to lg1 and lt1
      }
    }
  ]
};

************************* Event Listener ********************************

checkbox_1.addEventListener('click', function(e) {

  //change the values in places

}, false)





Upvotes: 1

Views: 35

Answers (1)

zahl
zahl

Reputation: 300

places.features[0].properties.name = "Trailer 2" places.features[0].geometry.coordinates[0]=lg1 places.features[0].geometry.coordinates[1]=lt1

Upvotes: 1

Related Questions