0

We are still rookie developers in HTML5 Builder, creating a Server Mobile Application.

We would like to know how to open another page (page2.php) using javascript.

Basically, the user will fill in a form, when the 'Submit' button is clicked, a few basic checks are done in javascript (like to check if all fields are filled in) and if validation is successful, the app needs to load the next page.

The following code have been tried:

window.location = "page2.php";

window.open('page2.php','_parent');

Both of these work fine when the app is running in a browser on the pc, but it does not work on the deployed app on Android, which will be the end product. We also tested it on more than one device with different versions of Android, with same result.

Any help will be appreciated, thank you.

Odione
  • 5
  • 3

1 Answers1

0

If you are using client-side AJAX navigation, which is enabled by default in mobile pages, you can change page with this:

$.mobile.changePage("TargetPage.php");
Gallaecio
  • 3,620
  • 2
  • 25
  • 64
  • Thank you for the reply. Tried it, but receiving a message in yellow: "Error Loading Page" I see the error message is the same as the Page's PageLoadErrorMessage property. The Page's UseAjax property is set to true. This is the exact OnClick: function btnTestJSClick($sender, $params) { ?> //begin js $.mobile.changePage("page2.php"); //end – Odione May 14 '13 at 14:35
  • Check that the submit button has the ButtonType property set to btNormal (otherwise, it submits the page to the server). – Gallaecio May 14 '13 at 14:38
  • ButtonType is set to btNormal – Odione May 14 '13 at 14:40
  • This works in PC Browser, but on Android phone it gives the error – Odione May 14 '13 at 14:43
  • Does TargetPage.php exist? Also, check that the Name property of both MPage pages is different — it’s a common error that haunts you when you less expect it. – Gallaecio May 14 '13 at 14:43
  • For Android, you might need to make some modifications to the code, replacing instances of TargetPage.php with TargetPage.html. See http://docwiki.embarcadero.com/HTML5_Builder/en/Distribution_Methods#PhoneGap for more information. – Gallaecio May 14 '13 at 14:44
  • yes, TargetPage.php (page2.php) does exist, it works when I use an MLink component to let the page show...but I need that extra validation. – Odione May 14 '13 at 14:45
  • The generated files must be keeping the .php extension in the JavaScript code, which should be replaced by .html on the deployment files. You might have to perform that change manually in the deployed files. – Gallaecio May 14 '13 at 14:47
  • I don't think I fully understand...sorry, can I maybe post/send a very basic example app? – Odione May 14 '13 at 15:00
  • When you use “Deploy to Mobile”, HTML5 Builder converts to client-side technologies (no PHP, only HMTL, JS and CSS) your application, to latter wrap it with PhoneGap. After the step in the Deploy to Mobile wizard where your files are exported, check the exported files, and see if among the .js files there are references to “page2.php”. You must replace those with “page2.html”. The **Embarcadero Forums** are a better place to talk about these things. – Gallaecio May 14 '13 at 15:13
  • There is not 1 php file in the deploy folder, only the html files. I will open a thread in the Embarcadero Forums as you suggested. Thanks Gallaecio :-) – Odione May 14 '13 at 15:20
  • I mean a reference to a .php file inside a .js file. That is, the text “page2.php” in a file with JavaScript code. That text should be repalced with “page2.html”, precisely because there are no .php files among the deployed files. – Gallaecio May 14 '13 at 18:16
  • Thank you very much Gallaecio, it is working 100% on Android when I change the code to: $.mobile.changePage("page2.html"); - It also makes sense when testing in the pc browser it should be page2.php but when deploying it should be changed to page2.html - your help is much appreciated! – Odione May 15 '13 at 07:56