JavaScript I want to draw the road map when i select the few location using checkbox.

I want to draw the road map when i select the few location using check boxes in form.php. I post that locations into map.php file, I assign that posted values into $location array and now I want to assign that $location array values into javascript calcRoute() function's waypoints array. How can I do that ?

<form action="map.php" method="post">

<input type="checkbox" name="check_list[]" value="horton" name="wildlife"> Horton Plains National Park <br>
<input type="checkbox" name="check_list[]" value="minneriya " name="wildlife"> Minneriya National Parks <br>
<input type="checkbox" name="check_list[]" value="galoye" name="wildlife"> Galoye National park<br>
<input type="checkbox" name="check_list[]" value="udawalawa" name="wildlife"> Uda Walawe National Park<br>
<input type="checkbox" name="check_list[]" value="wasgamuwa" name="wildlife"> Wasgomuwa National Park<br>
<input type="checkbox" name="check_list[]" value="yala" name="wildlife"> Yala West (Ruhuna) National Park 

</form>


<?php
$location = array();
if(isset($_POST['submit'])){
    if(!empty($_POST['check_list'])){
        foreach($_POST['check_list'] as $selected){
            $location = $selected;   
        }
    }
}

?>

function calcRoute() {
  var request = {
  origin: 'Colombo',
  destination: 'Colombo',
  waypoints:[{location: 'Kandy'}, {location: 'gampaha'}, {location: 'jaffna'}],  
  travelMode: google.maps.TravelMode.DRIVING
};
  directionsService.route(request, function(response, status) {
  if (status == google.maps.DirectionsStatus.OK) {
     directionsDisplay.setDirections(response);
  }
});

}

Answer:1

I am very very new to Angular and still very much a newbie to Javascript. I followed a tutorial, but the result is not working in my project. Tutorial: http://toddmotto.com/ultimate-guide-to-...

I am very very new to Angular and still very much a newbie to Javascript. I followed a tutorial, but the result is not working in my project. Tutorial: http://toddmotto.com/ultimate-guide-to-...

  1. angularjs scope not working
  2. angularjs scope watch not working
  3. angularjs scope apply not working
  4. angularjs scope broadcast not working
  5. angularjs scope function not working
  6. angularjs scope emit not working
  7. angularjs directive scope not working
  8. angularjs modal scope not working

I append the data from a json-object to a table: var array1 = $.map(data, function (field, i) { return '<tr><td>' + field.date + '</td><td>' + field.art + '</td><...

I append the data from a json-object to a table: var array1 = $.map(data, function (field, i) { return '<tr><td>' + field.date + '</td><td>' + field.art + '</td><...

For Google Apps Script for Google Docs, in the Sidebar.html file I use this code(simplified to remove irrelevant parts): <div class="sidebar branding-below"> <form> <div class="...

For Google Apps Script for Google Docs, in the Sidebar.html file I use this code(simplified to remove irrelevant parts): <div class="sidebar branding-below"> <form> <div class="...

  1. google apps script tutorial
  2. google apps script getrange
  3. google apps script documentation
  4. google apps script sheets
  5. google apps script logger
  6. google apps script api
  7. google apps script get sheet by name
  8. google apps script for loop
  9. google apps script reference
  10. google apps script dashboard
  11. google apps script triggers
  12. google apps script web app
  13. google apps script date
  14. google apps script editor
  15. google apps script array
  16. google apps script alert
  17. google apps script send email
  18. google apps script spreadsheet
  19. google apps script global variable
  20. google apps script libraries

jsFiddle: http://jsfiddle.net/az6Ug/ Using Snap.svg library, I want drag on the SVG and get the mouse position. I need the mouse position on the internal matrix, not the browser mouse position. I ...

jsFiddle: http://jsfiddle.net/az6Ug/ Using Snap.svg library, I want drag on the SVG and get the mouse position. I need the mouse position on the internal matrix, not the browser mouse position. I ...