将arraylist值从一个javascript传递到另一个javascript

时间:2011-12-19 06:25:37

标签: javascript android arraylist parameter-passing

我有一个值的arraylist必须从一个html(javascript)传递给另一个。

我的代码是:

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>  

和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>   

如何在脚本之间传递数据?

我通过以下方式解决了这个问题:

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

和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 " ); 

并在“列表”中向我展示“1%202”;

如何删除此%20 =空格值?

感谢
Sneha

1 个答案:

答案 0 :(得分:0)

你是说这个?

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("_"):[];  
}