Jump to content

Jquery mobile, phonegap pagechange


Craig Hopson

Recommended Posts

hi i wish to get a variable from the form (page1) onsubmit switch to (page2) and display value here is what i have but i cant get it to work, i get the "alert(Device_ID); " all fine but wont redirect

<!DOCTYPE html>    <head>		    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />		    <meta name="format-detection" content="telephone=no" />		    <meta name="viewport" content="width=device-width, initial-scale=1">		    <link rel="stylesheet" type="text/css" href="css/jquery-mobile.css" />		    <script type="text/javascript" src="js/cordova-2.2.0.js"></script>		    <script type="text/javascript" src="js/jquery.js"></script>		    <script type="text/javascript" src="js/jquery-mobile.js"></script>		    <title>CHTracker</title><script>function LogID(Form) {var Device_ID = Form.tracking_ID.value;  alert(Device_ID);$.mobile.changePage( "#page2", { transition: "slideup"} );   }</script>      </head>    <body>		<!-- Start of second page --><div data-role="page" id="page1"><div data-role="header">  <h1>CHTracker</h1></div><!-- /header --><div data-role="content">  <p>Please enter tracking ID:-</p>		    <p>			   		    <form method="post" data-ajax="false" onSubmit="LogID(this);">				    <div data-role="fieldcontain">						 <label for="tracking_ID">Tracking ID:-</label>						 <input type="text" name="tracking_ID" id="tracking_ID" />				    </div>  				    <input type="submit" value="Login" />		    </form>   </div><!-- /content --><div data-role="footer" data-position="fixed">  <h4>Page Footer</h4></div><!-- /footer --></div><!-- /page --><!-- Start of second page --><div data-role="page" id="page2"><div data-role="header">  <h1>CHTracker</h1></div><!-- /header --><div data-role="content">  <p>SOMETRACKING</p>		  </div><!-- /content --><div data-role="footer" data-position="fixed">  <h4>Page Footer</h4></div><!-- /footer --></div><!-- /page -->						     </body></html>

Link to comment
Share on other sites

At first glance I would say that the form is submitting and reloading the page. You should cancel the submission in the submit handler.
how? SOLVED
<form method="post" data-ajax="false" onSubmit="LogID(this);return false;">

Edited by Craig Hopson
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...