- This topic has 21 replies, 6 voices, and was last updated 11 years, 4 months ago by
support-octavio.
-
AuthorPosts
-
kevin94MemberHello i am new here, and i registered me here because i couldn’t find any help in the internet.
My problem is:
I want to run a JavaScript Code in MobiOne, that opens random pages.So if i would klick on a Button where stands: “Random”
i would to have a Random page (from 10 pages)
if it is important: all the 10 pages are in one multipage.Please could someone poste me the example code, i really need help.
Thanks so much.PS: Sorry for my bad english. -.-
April 3, 2013 at 1:59 pm #337482
BrandonMemberNot the only way to do it, but here is one way.
First create your multipage form and the button.
Then inside the button action select run javascript.
In side the javascript you will need something like this://Untested Code //random 1 to 10 n = Math.floor((Math.random()*10)+1); switch(n) { case 1: phoneui.gotoMultiPagePage('m1-yourform-multiPage1', 'SET_PAGE', 'm1-yourform-page1', phoneui.transitions.slideLeft); break; case 2: phoneui.gotoMultiPagePage('m1-yourform-multiPage1', 'SET_PAGE', 'm1-yourform-page2', phoneui.transitions.slideLeft); break; case 3: phoneui.gotoMultiPagePage('m1-yourform-multiPage1', 'SET_PAGE', 'm1-yourform-page3', phoneui.transitions.slideLeft); break; case 4: phoneui.gotoMultiPagePage('m1-yourform-multiPage1', 'SET_PAGE', 'm1-yourform-page4', phoneui.transitions.slideLeft); break; case 5: phoneui.gotoMultiPagePage('m1-yourform-multiPage1', 'SET_PAGE', 'm1-yourform-page5', phoneui.transitions.slideLeft); break; case 6: phoneui.gotoMultiPagePage('m1-yourform-multiPage1', 'SET_PAGE', 'm1-yourform-page6', phoneui.transitions.slideLeft); break; case 7: phoneui.gotoMultiPagePage('m1-yourform-multiPage1', 'SET_PAGE', 'm1-yourform-page7', phoneui.transitions.slideLeft); break; case 8: phoneui.gotoMultiPagePage('m1-yourform-multiPage1', 'SET_PAGE', 'm1-yourform-page8', phoneui.transitions.slideLeft); break; case 9: phoneui.gotoMultiPagePage('m1-yourform-multiPage1', 'SET_PAGE', 'm1-yourform-page9', phoneui.transitions.slideLeft); break; case 10: phoneui.gotoMultiPagePage('m1-yourform-multiPage1', 'SET_PAGE', 'm1-yourform-page10', phoneui.transitions.slideLeft); break; }
April 4, 2013 at 12:34 pm #337537
kevin94MemberYES, Thank you so much its working! 😀
April 4, 2013 at 2:36 pm #337544
BrandonMemberYou’re welcome, glad its working for you.
June 11, 2013 at 6:50 am #339836
RathinavelMemberHi,
it works for changing only one page at any instant….
I want to show that there are two pages being changed in one single button click, how can i do it.
Here is my Code,
refreshPage= function()
{
phoneui.gotoMultiPagePage(‘m1-proj1-mulpgTableOfContents’, ‘SET_PAGE’, ‘m1-proj1-pgMaterials’, phoneui.transitions.slideRight);phoneui.gotoMultiPagePage(‘m1-proj1-mulpgMainMenu’, ‘SET_PAGE’, ‘m1-proj1-page1’, phoneui.transitions.slideRight);
}In the above code,
The first line alone works good but not the second line.
immediate help is really appreciated 🙂
Warm Regards,
Vel.June 11, 2013 at 7:55 am #339838
BrandonMemberYou have two options.
1. You can use the post page transition, but this would only be if you want it to go to the second page every time.2. (What I would probably do) You could use a timer to to call the second page after a few seconds when the first page is done.
//start timer: 2 seconds
var myVar=setInterval(function(){myTimer()},2000);function myTimer()
{
//after the 2 seconds go to the second page
phoneui.gotoMultiPagePage(‘m1-proj1-mulpgMainMenu’, ‘SET_PAGE’, ‘m1-proj1-page1’, phoneui.transitions.slideRight);
//clear the timer so it doesnt do it again
clearInterval(myVar);
}June 12, 2013 at 1:13 am #339855
RathinavelMemberThanks alot Cincy Planet 🙂
It worked like a charm 🙂 🙂 🙂
Excited to see it working 😀 wow… :d
but One small problem…
I have a home button in page 3(BlogPost). when i click it, it should come to 2nd page(Main Contents) and then 1st page(Home).
Now what happens is the page transition happens, even if I go from 1st page to 2nd page, this once again goes to the 1st Page.. 🙁
cant this be restricted to only on click of the Home button…!?!
June 12, 2013 at 8:07 am #339871
BrandonMemberYou can call it from in a function:
function callTimer()
{myVar=setInterval(function(){myTimer()},2000);
}then in the run javascript of any button or any where you need it just call that function.
June 12, 2013 at 11:05 pm #339890
RathinavelMemberIt Works..!
Thanks a lot once again Cincy Planet 🙂
Day by day my love for MobiOne is Growing 🙂
June 13, 2013 at 6:46 am #339907
BrandonMemberGood to hear. Yes, there isn’t too much M1 can’t do. My latest app that was just released had a puzzle and a uses face detection for a fun feature (see the app showcase section).
June 13, 2013 at 8:04 am #339913
RathinavelMemberHi Cincy Planet,
I will have a look at my home (as my sister has the iPhone), and give you the review when I had used it 🙂nice to hear that you had developed a puzzle out of MobiOne… I’m Curious 🙂
Warm Regards,
Vel.June 13, 2013 at 8:21 am #339914
BrandonMemberThere is an Android version I just posted also.
June 14, 2013 at 12:53 am #339950
RathinavelMemberHi CincyPlanet,
I had a look at the android Version of the app.
Jessica Cameron Fan app (really it is).
its looking too good in look and feel 🙂
October 2, 2013 at 1:28 am #342909
temahantMemberat me it didn’t turn out (
give please mobi the fileFebruary 12, 2014 at 3:41 am #347082
johnjohnMemberI followed the example by CincyPlanet but I couldn’t get it to work.
My intention is my main file (main.mobi) has a button whereby pressing will randomly bring up any one of 5 pages (page1.mobi, page2.mobi etc).
The main changes i made to the code posted by CincyPlanet was
n = Math.floor((Math.random()*10)+1);
change to
n = Math.floor((Math.random()*5)+1)and
phoneui.gotoMultiPagePage(‘m1-yourform-multiPage1’, ‘SET_PAGE’, ‘m1-yourform-page1’, phoneui.transitions.slideLeft);
change to
phoneui.gotoMultiPagePage(‘m1-main’, ‘SET_PAGE’, ‘m1-page1’, phoneui.transitions.slideLeft);and delete all code from “case 6:” to “break;”
I am very new to programming and would appreciate some guidance.
Thanks.
-
AuthorPosts