www.webdeveloper.com
Results 1 to 3 of 3

Thread: Routing bus finder, can you help me?

  1. #1
    Join Date
    Feb 2014
    Posts
    2

    Question Routing bus finder, can you help me?

    Hello

    I like me create a bus routing finder, only City A (origin), City B (origin), search for the same routes in the cities and show the result

    For example
    City A - linebus 1, linebus 3, linebus 5
    City B - linebus 1, linebus 3, linebus 10

    Then should be show 1 and 3 can connect this cities

    I found this script online, I dont know it is possible use for my problem or adapt

    var city_A= ["bus1", "bus3", "bus5"]
    var city_B= ["bus1", "bus3", "bus10"]

    for(var i = 0; i<arr1.length; i++){
    for(var j=0; j<arr2.length; j++){
    if(arr1[i] === arr2[j]){
    //do something
    }
    }



    Or is wrong?

    Thanks

  2. #2
    Join Date
    Oct 2012
    Location
    Croatia
    Posts
    247
    Code:
            var city_A= ["bus1", "bus1", "bus5"];
            var city_B= ["bus1", "bus3", "bus10"];
            var conLines = [], message;
    
            for(var i = 0; i<city_A.length; i++){
                for(var j=0; j<city_B.length; j++){
                    if(city_A[i] === city_B[j]){
                        conLines.push(city_A[i]);
                    }
                }
            }
            
            message = (conLines.length > 0) ? "The following bus lines are able to connect routes betweene cities: " :
                                                "There are no alternative bus routes available!!!";
            alert(message + conLines.toString());

  3. #3
    Join Date
    Feb 2014
    Posts
    2
    Thanks for the help!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles