For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub
- This topic has 6 replies, 2 voices, and was last updated 13 years, 8 months ago by
mreade.
-
AuthorPosts
-
mreadeMemberSupport,
I would like my app to be able to do calculations in either Imperial or Metric.
I currently have a combolist box called “units” on the main.mobi startup screen. Here, users can select one of the two items:
* US (Imperial)
* Metric (SI)If the user selects the US mode, then the calculations on form calc.mobi will be in Imperials units. Or, if the Metric mode is selected, the calculations will be in Metric units.
What would you suggest is the best method to use, where should the code go, and should I use a If, Else type of statement to control the calculations?
Thanks in advance.
Mike
November 28, 2012 at 8:00 am #332803
mreadeMemberSupport,
Can you get me going in the right direction? I am looking to use a Combobox to select calculation mode (Imperial vs. Metric).
What code would you suggest and where would you suggest placing it?
Thanks
Mike
November 29, 2012 at 8:28 am #332863
mreadeMemberIf anyone can assist here, I would appreciate your comments.
function calcMode() { var US var SI var mode US = $('select[name="m1-frmMain-units"]:selected').text("imperial"); SI = $('select[name="m1-frmMain-units"]:selected').text("metric"); mode = $('select[name="m1-frmMain-units"]:selected').text(); if (mode = US) { //Place code to perform imperial calculations here alert("g = 32.2"); } else { //Place code to perform metric calculations here alert("g = 9.81"); } }I have a Combobox called “units” on the main startup form (frmMain.mobi) and just to test this a button to trigger the function calcMode () to show either mode.
With the combobox (units) showing imperial, it shows imperial mode alert fine. However, with the combobox showing metric, it still shows imperial mode alert, and not the metric alert.
I am sure there is something simply I am missing. All assistance would be appreciated.
Thanks in advance
November 29, 2012 at 12:46 pm #332866
support-octavioMemberI’ve modified your function and worked fine :
function calcMode()
{
var mode = $(‘select[name=”units”] :selected‘).text();if (mode == “Imperial”)
{
//Place code to perform imperial calculations here
alert(“g = 32.2”);
}
else
{
//Place code to perform metric calculations here
alert(“g = 9.81”);
}
}I highlighted the changes I did to make it work.
November 29, 2012 at 1:02 pm #332868
mreadeMemberOctavia,
Many thanks!
I will give this a try and let you know how I make out.
Mike
November 29, 2012 at 1:22 pm #332869
mreadeMemberOctavio,
YES!
This did work after I put a space between the ” ] ” and the ” : ”
You have saved me a few brain cells trying to figure this out for the first time.
Cheers!
Mike
PS: Is there a way now to save the state “Imperial” or “Metric” and use same the next time the app is run?
Soooo, much to learn. 🙂
November 30, 2012 at 6:48 am #332914
mreadeMemberOctavio,
This is working perfectly now, thanks to your suggestion.
I have implemented this in two forms, where those forms look to the main form for the combobox units setting. Both the results and the email body message show the proper format, calculation mode and units.
You may mark this as CLOSED.
Many thanks!
Mike
-
AuthorPosts
