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

  • Home
  • SEARCH
  • 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 9160641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:47:10+00:00 2026-06-17T13:47:10+00:00

i’m kinda noobish when it comes to javascript. I have a Google maps simple

  • 0

i’m kinda noobish when it comes to javascript. I have a Google maps simple script for routing directions from A to B. It all works well, except i would like to change the mode (driving, walking…) from currect drop down selector to radio buttons.

I’ve searched on the net and stackoverflow, but currently did not find a working solution for this.

My html:

<select id="mode">
     <option selected="selected" value="DRIVING">Car</option>
     <option value="WALKING">Walk</option>
     <option value="TRANSIT">Public transport</option>
     <option value="BICYCLING">Bike</option>
</select>

and script:

function calcRoute() {
var selectedMode = document.getElementById('mode').value;
var start = document.getElementById("routeStart").value;
var end = document.getElementById("routeEnd").value;
var request = {
    origin: start,
    destination: end,
    travelMode: google.maps.TravelMode[selectedMode]
};

Is it possible to change select (dropdown) to be radio buttons from the code above or should i post something else also?

p.s.
I’ve also tried this solution, but when i submit Calculate route it just redirects me to a blank subpage /mode?.

Thanks 🙂

  • 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-17T13:47:11+00:00Added an answer on June 17, 2026 at 1:47 pm

    I hope you are talking about Radio Buttons instead of Checkbox as multiple checkboxes can be selected which will not work as expected. Radio buttons come in groups which have the same name and different ids, one of them will have the checked property set to true, so loop over them until you find it.

    Create a new function to find radio button which is checked and then replace
    var selectedMode = document.getElementById(‘mode’).value; with the code given below:

    function getCheckedRadio(radio_group) {
        for (var i = 0; i < radio_group.length; i++) {
            var button = radio_group[i];
            if (button.checked) {
                return button;
            }
        }
        return undefined;
    }
    
    var selectedMode = getCheckedRadio(document.forms.frmId.elements.groupName).value;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small JavaScript validation script that validates inputs based on Regex. I
I have a text area in my form which accepts all possible characters from
I'm making a simple page using Google Maps API 3. My first. One marker
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
I have an autohotkey script which looks up a word in a bilingual dictionary
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a bunch of posts stored in text files formatted in yaml/textile (from
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.