0

I have an arraylist of values which must be passed from one html (javascript) to another.

My code is :

function show_confirm()  
{  
     //var r=confirm("Do you wish to use the existing Details?");
     apprise('Do you wish to use the existing details?', {'verify':true}, function(r)  
                {  
                if(r)  
                    {   
                    // user clicked 'Yes'  
                alert("yes");  
                var a=camera.getDetails();  
                //window.locaton="http://www.google.co.in/";  
                var s=a.get(0);  
                alert(s);  
                //alert("rettttttttt" + a);  
                window.location="my_details.html?" + s;  
               //document.getElementById("location").value=a.get(0) + " ";  

                //alert(a.get(0) + " ");  
                //fetch my details from native  

                   }  
                else  
                  { 
                   // user clicked 'No'  
                  // display new form  
                 alert("no");  
                    }  
                });  

 }  
 </script>  

and in my_details.html :

 function submitForm(){  

     //var policyNumber=document.getElementById("number").value;
    //var a=camera.getDetails();
     var q=window.location.search;  
     if (q.substring(0, 1) == '?') {  
         q = query.substring(1);  
     }  
       alert("qqqqqqqqqq "+ q);  
 </script>   

How to pass data between scripts?

I resolved it in the following way:

 var c=new Array(a);    (eg: a={"1","2"})
 window.location="my_details.html?"+  c + "_";     

and in my_details.html :

var q=window.location.search;   
alert("qqqqqqqqqqqqq " + q);  
var arrayList = (q)? q.substring(1).split("_"):[];     
var list=new Array(arrayList);  
 alert("dataaaaaaaaaaaa " +  list  + "llll " ); 

and in "list" its dusplaying me "1%202";

How can i remove this %20 =space value ??

thanks
Sneha

Smitha
  • 6,110
  • 24
  • 90
  • 161
  • What's an "arraylist" (in a JavaScript context)? Do you mean the query string arguments, i.e., the bit after the "?" at the end of the URL? Because you seem to have the basic pieces already in place for that. What is the specific problem you are having with it? – nnnnnn Dec 19 '11 at 06:34
  • the variable "a " gets an array or arraylist in the javascript in line "a=camera.getDetails(); " and i want to pass this to my_details.html – Smitha Dec 19 '11 at 06:37
  • what you are trying to do is fine but you nee to pass the data properly a retrieve it in submitForm() .. please check this for parsing data from url http://stackoverflow.com/questions/814613/how-to-read-data-from-a-url-using-javascript – Sarath Dec 19 '11 at 06:51
  • and please check the data in a , if its an array convert it to string with join method .. can you show what exactly "a" is .? – Sarath Dec 19 '11 at 07:10

1 Answers1

0

You mean this?

function show_confirm() {  
  //var r=confirm("Do you wish to use the existing Details?");
  apprise('Do you wish to use the existing details?', {'verify':true}, function(r) {  
    if(r) {
      // user clicked 'Yes'  
      var a=camera.getDetails();  
      window.location="my_details.html?" + a.join("_");  
    }  
    else { 
      alert("no");  
    }  
  });  
}  

function submitForm(){  
  var q=window.location.search;  
  var arrayList = (q)? q.substring(1).split("_"):[];  
}
mplungjan
  • 169,008
  • 28
  • 173
  • 236