On Wed, 2010-05-26 at 04:21 -0700, Andrew Leach wrote:
> On May 26, 12:08 pm, arshad <[email protected]> wrote:
> > and yes it pops out alert for me too. but the output is wrong and i have
> > set it to output sort of hardcode values (alert("Please Take this Bus
> > "+str1Array[0]+","+str1Array[1]+","+str1Array[2]);)
> > because the correct output is suppsed to be from resultArray and its not
> > working. thus i commented that line, please see: line (87)
> > alert("Please Take this Bus
> > "+str1Array[0]+","+str1Array[1]+","+str1Array[2]);
> > //alert("Please Take this Bus "+resultArray[0]);
> 
> Right, so the question is "How do I join the values in an array into a
> single string for output?"
> 
> alert("Please take this bus: "+resultArray.join(", "))
> outputs all the elements of resultArray separated by a comma and a
> space.
> 

hi andrew thanks for your contant help,

i make the alerts like this:

alert("Please Take this Bus
"+str1Array[0]+","+str1Array[1]+","+str1Array[2]);

//alert("Please Take this Bus "+str1Array[0].join(", "));

//alert("Please Take this Bus "+resultArray[0].join(", "));


only the first way pops out an alert. the rest don't do anything.
to give a clear picture of what i want;

1)
if i select from the combo the values first and second the output should
be: 100, 101

2)
if i select first and third the output should be: 400, 430, 02

3)
if i select first and four the output should be: 100, 101, 02

4)
if i select third and fourth the output should be: 02

please see below snippet:

thank you very much again.
====================================

var loc1="Wellawatte Police Station, Sri Lanka";
        var loc2="Waidya Rd, Sri Lanka";
        var loc3="Havelock Town, Sri Lanka";
        var loc4="Slave Island, Sri Lanka";

//array consisting the bus numbers of locations
        var loc1Array=new Array("100", "101", "400", "430", "02");
        var loc2Array=new Array("100", "101");
        var loc3Array=new Array("400", "430", "02");
        var loc4Array=new Array("100", "101",  "02");


        function print_(input1, input2){
        
        switch(input1){
        case "Wellawatte Police Station, Sri Lanka": str1Array=loc1Array;break;
        case "Waidya Rd, Sri Lanka": str1Array=loc2Array;break;
        case "Havelock Town, Sri Lanka": str1Array=loc3Array;break;
        case "Slave Island, Sri Lanka": str1Array=loc4Array;break;
        default: str1Array=loc2Array;
        }

switch(input2){
        case "Wellawatte Police Station, Sri Lanka": str2Array=loc1Array;break;
        case "Waidya Rd, Sri Lanka": str2Array=loc2Array;break;
        case "Havelock Town, Sri Lanka": str2Array=loc3Array;break;
        case "Slave Island, Sri Lanka": str2Array=loc4Array;break;
        default: str2Array=loc2Array;
        }
        
        //function starts here
        function check(str1Array, str2Array){
var a=0;

if(str1Array.length<str2Array.length)
        resultArray=new Array[str2Array.length];
else
        resultArray=new Array[str1Array.length];
var i=0;
for(i=0;i<str1Array.length;i++){
        var j=0;
        for(j=0;j<str2Array.length;j++){
        if(str1Array[i]==str2Array[j])
        {
                resultArray[a++]=str1Array[i];
        }
        }
} resultArray1=resultArray;
}
//function ends here

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-api?hl=en.

Reply via email to