Form processing onClick isn't being activated if I come from another page with jQuery Mobile
Hey all!
I'm creating a website that uses lots of forms and jQuery Mobile. I'm having a problem where if I'm on a page with jQuery Mobile and I go to another page with jQuery Mobile, then on the page that I go to my form isn't being processed onClick. In this post I'm going to be talking about two pages, Reports.php and DataManipulation.php. By the way if I refer to files or ids or classes that aren't in this post, be sure that I have them because I do, I just wanted to keep this post shorter.
Can you please help me find out why,
when I come from a page with jQuery Mobile to another page with jQuery Mobile and a form, the page that I come to with the form isn't processed onClick?
Here is what is in the head tag for both pages (I'm not going to show my head tag in my files as to keep this post shorter, but it is there):
- <title>MIS</title>
- <link rel="stylesheet" href="../css/jQueryMobile.css"> <!--Link to the jQuery Mobile css file, modified for my purposes-->
- <link rel="stylesheet" href="../css/Main.css"> <!--Link to my css file-->
- <script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
- <script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
- <script src="../scripts/js/Normalize.js"></script> <!--Link to a file that disables some of jQuery Mobile's classes for purposes of jQuery Mobile's css not interfering with my css-->
Here is my Normalize.js file (just in case you wanted to see it):
- $(document).on('pagebeforeshow', 'html', function() {
- $('body').removeClass('ui-mobile-viewport');
- $('body').removeClass('ui-overlay-viewport');
- $('div').removeClass('ui-page-theme-a');
- $('div').removeClass('ui-btn');
- $('div').removeClass('ui-input-btn');
- $('div').removeClass('ui-corner-all');
- $('div').removeClass('ui-shadow');
- $('div').removeClass('ui-input-text');
- $('div').removeClass('ui-body-inherit');
- $('div').removeClass('ui-shadow-inset');
- });
Here is my Reports.php page:
- <!DOCTYPE html>
- <html>
- <body>
- <div data-role="page" class="frame" id="report">
- <div class="header">
- <?php include("../scripts/php/ReportsHeader.php");?>
- </div>
- <div class="main">
- <h3>Would you like to view a report grouped by customers, items, sales departments, or sales people?</h3>
- <form data-ajax="false" method="post" class="form" id="reportform">
- <input type="radio" name="report" value="customer"><p>Customers</p>
- <input type="radio" name="report" value="item"><p>Items Sold</p>
- <input type="radio" name="report" value="department"><p>Sales Departments</p>
- <input type="radio" name="report" value="person"><p>Sales People</p>
- <input type="button" data-role="none" name="reportsubmit" value="Submit" onClick="checkReport(this.form)">
- </form>
- </div>
- </div>
- <div data-role="page" class="frame" id="customer">
- <div class="header">
- <?php include("../scripts/php/ReportsHeader.php");?>
- </div>
- <div class="main">
- <h3>Would you like to view a cumulative report of all customers, or a single report of just one?</h3>
- <form data-ajax="false" method="post" class="form">
- <input type="radio" name="customer" value="all"><p>All</p>
- <input type="radio" name="customer" value="one"><p>One</p><br>
- <input type="button" data-role="none" name="customersubmit" value="Submit" onClick="checkCustomer(this.form)">
- </form>
- </div>
- </div>
- <script src="../scripts/js/Reports.js"></script>
- </body>
- </html>
Here is my Reports.js file:
- function checkReport(form) {
- var checked = form.querySelector('input:checked');
- var value = checked ? checked.value : null;
-
- if (value == "customer") {
- var href = "http://bdpastudents.com/~a7068104/2013-2014/Lab_13/Reports/Reports.php";
- var idx = href.indexOf("Reports", 0);
- var new_href = href.slice(0, idx + 19) + "#customer" + href.slice(idx + 19);
-
- window.location.replace(new_href);
- } else if (value == "item") {
- var href = "http://bdpastudents.com/~a7068104/2013-2014/Lab_13/Reports/Reports.php";
- var idx = href.indexOf("Reports", 0);
- var new_href = href.slice(0, idx + 19) + "#item" + href.slice(idx + 19);
-
- window.location.replace(new_href);
- } else if (value == "department") {
- var href = "http://bdpastudents.com/~a7068104/2013-2014/Lab_13/Reports/Reports.php";
- var idx = href.indexOf("Reports", 0);
- var new_href = href.slice(0, idx + 19) + "#department" + href.slice(idx + 19);
-
- window.location.replace(new_href);
- } else if (value == "person") {
- var href = "http://bdpastudents.com/~a7068104/2013-2014/Lab_13/Reports/Reports.php";
- var idx = href.indexOf("Reports", 0);
- var new_href = href.slice(0, idx + 19) + "#person" + href.slice(idx + 19);
-
- window.location.replace(new_href);
- }
- }
Here is my DataManipulation.php file:
- <!DOCTYPE html>
- <html>
- <body>
- <div data-role="page" class="frame" id="data">
- <div class="header">
- <?php include("../scripts/php/DataManipulationHeader.php");?>
- </div>
- <div class="main">
- <h3>Would you like to insert data into the database, update data in the database, or delete a row in the database?</h3>
- <form data-ajax="false" method="post" class="form" id="reportform">
- <input type="radio" name="data" value="insert"><p>Insert</p>
- <input type="radio" name="data" value="update"><p>Update</p>
- <input type="radio" name="data" value="delete"><p>Delete</p>
- <input type="button" data-role="none" name="datasubmit" value="Submit" onClick="checkData(this.form)">
- </form>
- </div>
- </div>
- <script src="../scripts/js/DataManipulation.js"></script>
- </body>
- </html>
And finally here is the DataManipulation.js file:
- function checkData(form) {
- var checked = form.querySelector('input:checked');
- var value = checked ? checked.value : null;
-
- if (value == "insert") {
- var href = "http://bdpastudents.com/~a7068104/2013-2014/Lab_13/DataManipulation/Insert.php";
- window.location.replace(href);
- } else if (value == "update") {
- var href = "http://bdpastudents.com/~a7068104/2013-2014/Lab_13/DataManipulation/Update.php";
- window.location.replace(href);
- } else if (value == "delete") {
- var href = "http://bdpastudents.com/~a7068104/2013-2014/Lab_13/DataManipulation/Delete.php";
- window.location.replace(href);
- }
- }
Can you please help me find out why,
when I come from a page with jQuery Mobile to another page with jQuery Mobile and a form, the page that I come to with the form isn't processed onClick?
Thank you!