I have a JS file that takes a value from an HTML page. I have to use this variable inside CSS embedded in JS

I use simplemaps and this is a js file where the function is used to get values ​​from an HTML page.

Javascript function

function getValue(intvalue){
alert(intvalue);
var mapval = intvalue;
}
var simplemaps_worldmap_mapdata = {


main_settings:{
//General settings
width:1004,
background_color: '#FFFFFF', 
background_transparent: 'no',
border_color: '#FFFFFF',
zoom: 'yes',
pop_ups: 'detect', //on_click, on_hover, or detect

//Country defaults
state_description:   'Country description',
state_color: '#88A4BC',
state_hover_color: '#3B729F',
state_url: 'http://simplemaps.com',
all_states_inactive: 'no',

//Location defaults
location_description:  'Location description',
location_color: '#FF0067',
location_opacity: 1,
location_url: 'http://simplemaps.com',
location_size: 35,
location_type: 'circle', //or circle
all_locations_inactive: 'no',

url_new_tab: 'no',  
initial_zoom: 1,   
initial_zoom_solo: 'no',
auto_load: 'yes',
hide_labels: 'no'  
},
}//end of simplemaps_worldmap_mapdata

I need to dynamically pass the value to the "initial scaling" field, the color field. With a different value, it scales the image at different levels.

0
source share
1 answer

I don’t understand what exactly you are asking, but I think you need to access the main_settings object

You can access the object of the object

simplemaps_worldmap_mapdata.main_settings.initial_zoom

and

simplemaps_worldmap_mapdata["main_settings"]["initial_zoom"];

read it

0
source

All Articles