- This topic has 21 replies, 6 voices, and was last updated 11 years, 2 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. -.-
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; }
kevin94MemberYES, Thank you so much its working! 😀
BrandonMemberYou’re welcome, glad its working for you.
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.
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);
}
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…!?!
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.
RathinavelMemberIt Works..!
Thanks a lot once again Cincy Planet 🙂
Day by day my love for MobiOne is Growing 🙂
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).
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.
BrandonMemberThere is an Android version I just posted also.
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 🙂
temahantMemberat me it didn’t turn out (
give please mobi the file
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