Link to home
Start Free TrialLog in
Avatar of Eduardo Fuerte
Eduardo FuerteFlag for Brazil

asked on

How to make an image presented by default and then changed dinamically accordingly with users choice?

Hi Experts

I'm working with maps that must be presented accordingly with the user option.

When the page starts  the map "TODOS" has to be presented  and the radio button 'TODOS' option choosed.
User generated image
Acctually if  'TODOS',  'PNAE' or  'PPAIS' options  is assigned the correspondently map appear, correctly.
(in the case of TODOS first I must change to another option and then return to it)

Following the pictures  
User generated image
and
User generated image
here the code I use:
<!doctype html>
<html>
<head>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<link href="css/custom.css" rel="stylesheet" />

<style type="text/css">
.map-frame {
  display: none;
}
</style>

</head>

<body>

<div class="wrapper">
<div class="container">

<?php $random = rand(10,1000) ?>

<div id="todos" class="map-frame">
    <iframe width='105%' height='600px' frameBorder='0' src='https://a.tiles.mapbox.com/v4/efuerte.xxxxx/attribution.html?q=<?php echo($random) ?>&access_token=pk.xxxxxx'></iframe>
</div>

<div id="pnae" class="map-frame">
     <iframe width='105%' height='600px' frameBorder='0' src='https://a.tiles.mapbox.com/v4/efuerte.oxxxx/attribution.html?q=<?php echo($random) ?>&access_token=pk.xxxxxxxxxxx'></iframe>
</div>

<div id="ppais" class="map-frame">
    <iframe width='105%' height='600px' frameBorder='0' src='https://a.tiles.mapbox.com/v4/efuerte.o30822h8/attribution.html?q=<?php echo($random) ?>&access_token=pk.xxxxxxxxxx'></iframe>
</div>

<input type="radio" name="editList" data-target="todos" class="map-select" checked=""/>TODOS 
<input type="radio" name="editList" data-target="pnae" class="map-select"/>PNAE
<input type="radio" name="editList" data-target="ppais" class="map-select"/>PPAIS

</div>
</div>

<script src="http://code.jquery.com/jquery.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script>
$(function() {
  $('.map-select').change(function() {
     var selector = '';
     $('.map-select:checked').each(function() {
        selector += $(this).data('target');
     });
     $('.map-frame').hide();
     $('#' + selector).show();
  });
});
</script>
</body>
</html>

Open in new window


So, I need the map TODOS presented when the page opens. Like that:
User generated image
Could you suggest how could I get the job done by change the code I get?

Thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Eduardo Fuerte

ASKER

Very good!

Thanks for the assistance!
You are welcome Eduardo,
Hello Julian!

I post another question referencing this subject ... when embeding the code in the original page.. something unexpected occurs....