Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8365077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:34:34+00:00 2026-06-09T12:34:34+00:00

I have a small map and I want to show two different information categories

  • 0

I have a small map and I want to show two different information categories on it separately. I have put two radio buttons on my code which allows users to select one of these category names and when a user move a mouse over a map the information which are related to the specific radio button should be appeared. my below code works only for first radio button and when I choose the second radio button again the first information are shown! can you help me what should I do? meanwhile the structure of my code works but I can’t write all of them here.

Here is my code:
the information is store in the below matrix:

var myCantons = [];
myCantons[0]=[name,year,population,density,year,population,density];
myCantons[1]=[x,1982,1200000,1.2,1992,300000,1.8];
myCantons[2]=[y,1982,5000000,4,1992,390000,4.6];

The radio buttons are:

<form action="">
   <input type="radio" name="againcies" value="SP" 
     "onchange="myShowValues(myEvent)"/>
   <input type="radio" name="againcies" value="Moody"            
     "onchange="myShowValues(myEvent)"/>

The function is:

function myShowValues(myEvent,detaset){
  if(dataset==1){
    document.getElementById('myLegCantName').firstChild.data =  myCantons[Id][0];
    document.getElementById('year').firstChild.data = myCantons[Id][1];
    document.getElementById('myLegCantVal').firstChild.data =(myCantons[Id][2]);
    document.getElementById('myLegCantVal2').firstChild.data =(myCantons[Id][3]);
  } else {
    document.getElementById('myLegCantName').firstChild.data = myCantons[Id][0]      
    document.getElementById('myLegCantRate').firstChild.data = myCantons[Id][4];
    document.getElementById('myLegCantVal').firstChild.data =(myCantons[Id][5]);                      
    document.getElementById('myLegCantVal2').firstChild.data =(myCantons[myScrId][6]);
  }
}

The map includes of lots of polygon which are in one group like this:

<g id="myCantons" fill="#A0C544" stroke="#FFFFFF" onmouseover="myShowValues(evt,dataset)">

My problem as mentioned before is in if condition part it can call only for first radio button and I am not able to apply if condition for second button, do you have any idea?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:34:35+00:00Added an answer on June 9, 2026 at 12:34 pm

    Try doing something like this :

    <input type="radio" name="againcies" value="SP" 
     onchange="changeDataset(1)"/>
    <input type="radio" name="againcies" value="Moody"            
     onchange="changeDataset(2)"/>
    

    and

    <g id="myCantons" fill="#A0C544" stroke="#FFFFFF" onmouseover="myShowValues()">
    

    Then javascript like this :

    var dataset = 1; // default value
    function changeDataset(newval) {
       dataset = newval;
       // plus whatever else you need to do here
       // maybe myShowValues(); ???
    }
    
    function myShowValues(){
      if(dataset == 1){
         document.getElementById('myLegCantName').firstChild.data =  myCantons[Id][0];
         document.getElementById('year').firstChild.data = myCantons[Id][1];
         document.getElementById('myLegCantVal').firstChild.data =(myCantons[Id][2]);
         document.getElementById('myLegCantVal2').firstChild.data =(myCantons[Id][3]);
      } else {
         document.getElementById('myLegCantName').firstChild.data = myCantons[Id][0]      
         document.getElementById('myLegCantRate').firstChild.data = myCantons[Id][4];
         document.getElementById('myLegCantVal').firstChild.data =(myCantons[Id][5]);                      
         document.getElementById('myLegCantVal2').firstChild.data =(myCantons[myScrId][6]);
      }
    }
    

    A couple of things to note .. this isnt valid HTML :

    "onchange="myShowValues(myEvent)"
    

    there are too many quotes …

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small program I want to execute to test something #include <map>
I have integer values ranging from 32-8191 which I want to map to a
i have a small map of a town, i want to place it into
I have a small code example I want to include in the Javadoc comment
I have a small map on my view that I want to drop an
I have a group of borders that make up a small map. Ideally I'd
I have small script in bash, which is generating graphs via gnuplot. Everything works
I am a Python newbie. I have this small problem. I want to print
I have an hadoop job with a pretty long map phase and I want
Hi have an array of cities and want to create a google map using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.