javascript - Parameters are passing but not retrieving when mobile.changepage in jquerymobile -


hello have search field search button , 2 drop-down list values when click search button want pass parameter values using mobile.change method.i using following structure

page1.html

<!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>client view</title> <link rel="stylesheet" href="css/jquery.mobile-1.3.2.min.css" /> <script src="js/jquery-1.10.2.js"></script> <script src="js/jquery.mobile-1.3.2.min.js"></script> <script type="text/javascript">   $(document).on('pagebeforeshow',function(){      $("#searchbutton").on('click',function(){     var searchvalue = $("[name='clientsearch']").val();   var searchbyvalue = $("#select-choice-searchby").val();   var statusvalue = $("#select-choice-status").val();     $.mobile.changepage(      'accountlist.html',     {       //dataurl : "accountlist.html?searchvalue="+searchvalue&"searchbyvalue="+searchbyvalue&"statusvalue="+statusvalue ,      data : { 'searchvalue' : searchvalue,'searchbyvalue':searchbyvalue,'statusvalue':statusvalue },      reloadpage : false,      changehash : true      });   }); });  </script> </head>  <body>  <!--client page-->           <div data-role="page" id="client" data-add-back-btn="true" >          <div data-role="header" data-theme="b" data-position="fixed" data-id="persistantfooter">  <h1>client view</h1> </div> <div data-role="content">     <div data-role="fieldcontain" id="searchbox">      <input type="search" name="clientsearch" value="" data-inline="true" data-mini="true"/>      <input type="button" value="search" data-inline="true" data-theme="b" data-mini="true" id="searchbutton"/>     </div>      <div data-role="fieldcontain"  >          <label for="select-choice-searchby"  class="select" data-inline="true" style = "width: 90px">search by:</label>          <select name="select-choice-searchby" id="select-choice-searchby" data-inline="true" data-mini="true" style = "float: right">             <option value="account">account</option>             <option value="customhouseholds">custom households </option>             <option value="roahouseholds">roa households</option>         </select>         </div>         <div data-role="fieldcontain"  >         <label for="select-choice-status"  class="select" data-inline="true" style = "width: 90px">status:</label>          <select name="select-choice-status" id="select-choice-status" data-inline="true" data-mini="true" style = "float: right">             <option value="open">open</option>             <option value="closed">closed </option>             <option value="all">all</option>         </select>     </div> </div>  </div>   </body>  </html> 

page2.html:

<!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8">  <title>account view</title> <link rel="stylesheet" href="css/jquery.mobile-1.3.2.min.css" /> <script src="js/jquery-1.10.2.js"></script> <script src="js/jquery.mobile-1.3.2.min.js"></script> <script type="text/javascript">  $(document).on('pagebeforeshow',function(){ alert("hi"); //  var parameters = window.location.pathname.split("?")[1]; //alert(geturlvars()) var searchvalue = geturlvars()[0];  var searchbyvalue = geturlvars()[1];  var statusvalue = geturlvars()[2];  alert(searchvalue);  function geturlvars() {     var qname = [], hash;     var qval=[];     var hashes = window.location.href.slice(window.location.href.indexof('?') + 1).split('&');     for(var = 0; < hashes.length; i++)     {         hash = hashes[i].split('=');         qname.push(hash[0]);         qval.push(hash[1]);         qname[hash[0]] = hash[1];     }     return qval;     }        });      // javascript document     </script>  </head>    <body>     <div data-role="page" id="accountlist" data-add-back-btn="true" >     <div data-role="header" data-theme="b">         <h3>account view</h3>     </div>     <div data-role="content">      </div> <!--content--> </div><!--page-->     </body>         </html> 

in page2.html cannot access parameter values , script function not execute how fix this

try this: have considered single page concept, can change code accordingly:

<!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>client view</title>    <link rel="stylesheet" href="http://view.jquerymobile.com/1.3.2/dist/demos/css/themes/default/jquery.mobile.min.css" />   <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>   <script type="text/javascript" src="http://view.jquerymobile.com/1.3.2/dist/demos/js/jquery.mobile.min.js"></script>  </head>  <body>  <!--client page-->           <div data-role="page" id="client" data-add-back-btn="true" >          <div data-role="header" data-theme="b" data-position="fixed" data-id="persistantfooter">  <h1>client view</h1> </div> <div data-role="content">     <div data-role="fieldcontain" id="searchbox">      <input type="search" name="clientsearch" value="" data-inline="true" data-mini="true"/>      <input type="button" value="search" data-inline="true" data-theme="b" data-param1="" data-param2 ="" data-param3="" data-mini="true"  id="searchbutton"/>     </div>      <div data-role="fieldcontain"  >          <label for="select-choice-searchby"  class="select" data-inline="true" style = "width: 90px">search by:</label>          <select name="select-choice-searchby" id="select-choice-searchby" data-inline="true" data-mini="true" style = "float: right">             <option value="account">account</option>             <option value="customhouseholds">custom households </option>             <option value="roahouseholds">roa households</option>         </select>         </div>         <div data-role="fieldcontain"  >         <label for="select-choice-status"  class="select" data-inline="true" style = "width: 90px">status:</label>          <select name="select-choice-status" id="select-choice-status" data-inline="true" data-mini="true" style = "float: right">             <option value="open">open</option>             <option value="closed">closed </option>             <option value="all">all</option>         </select>     </div> </div>  </div>  <div data-role="page" id="accountlist" data-add-back-btn="true" >     <div data-role="header" data-theme="b">         <h3>account view</h3>     </div>     <div data-role="content">      </div> <!--content--> </div><!--page-->  <script type="text/javascript">   $("#client").on('pageshow',function(){      $("#searchbutton").on('click',function(){     var searchvalue = $("[name='clientsearch']").val();   var searchbyvalue = $("#select-choice-searchby").val();   var statusvalue = $("#select-choice-status").val();     $("#searchbutton").data("param1", searchvalue);   $("#searchbutton").data("param2", searchbyvalue);   $("#searchbutton").data("param3", statusvalue);      $.mobile.changepage(      '#accountlist', {          reloadpage : false,      changehash : true      });   }); });  $("#accountlist").on('pageshow',function(){     alert( $("#searchbutton").data("param1"));     alert( $("#searchbutton").data("param2"));     alert( $("#searchbutton").data("param3")); });   </script>   </body>  </html> 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -