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, 3 voices, and was last updated 12 years, 5 months ago by
support-octavio.
-
AuthorPosts
-
Robert GardnerParticipantI’m having some difficulty trying to construct a series of nested IF statements in Javascript. I know what I would do in other languages (old school stuff like Cobol, Assembler).
Here’s what I need to do… Consider.. The checkbox will either be set or not. The other comparison values will either be 1, 2 or 3. Calculation is different depending upon the combination of the checkbox and other value (1 2 or 3).
If (variable_name == “1”) && (checkbox value is SET)
then totalcharges = non-regularRate1 * qty
If (variable name ==”1″ && (checkbox value is NOT SET)
the totalcharges = regularRate1 * qty.If (variable_name == “2”) && (checkbox value is SET)
then totalcharges = non-regularRate2 * qty
If (variable name ==”2″ && (checkbox value is NOT SET)
the totalcharges = regularRate2 * qty.If (variable_name == “3”) && (checkbox value is SET)
then totalcharges = non-regularRate2 * qty
If (variable name ==”3″ && (checkbox value is NOT SET)
the totalcharges = regularRate3 * qty.Can’t seem to wrap my head around it? One issue I’m having is placing braces and ; properly. Can anyone share a solution?
As you might imaging I’m fairly new to JS..
Thanks,
October 15, 2013 at 9:11 am #343358
BrandonMemberTry something like this:
if($(‘#form1-toggle1 input’).is(‘:checked’) == true && myVariable == ‘1’)
{
//do this
}References
http://www.genuitec.com/mobile/docs/widgetReference/widgetReference.html#list_propertiesOctober 15, 2013 at 9:39 am #343360
Robert GardnerParticipantdoesn’t this statement state if BOTH are true?
if($(‘#form1-toggle1 input’).is(‘:checked’) == true && myVariable == ‘1’)
If so, I need something that says if the checkbox is not TRUE
also… I posted in another post questioning why when I save the value of the checkbox to a variable it always has the value of ON regardless of the box being checked or not… Do you know what’s happening there?
Thank you for your prompt response..
October 15, 2013 at 9:48 am #343361
Robert GardnerParticipantI tried the == true and also != true implementations by themselves (not using the compound condition) to see if either would work… They didn’t
October 15, 2013 at 9:54 am #343362
BrandonMemberIf its unchecked it will be false instead of true.
You can also make sure you are getting a result by setting the value in a n alert:alert($(‘#form1-toggle1 input’).is(‘:checked’));
This will help make sure you get the form name and widget name correct.
If it is not returning true or false something is wrong.October 15, 2013 at 10:17 am #343364
Robert GardnerParticipantWell,… the devil is always in the details…. Upon closer look at your widget construction I noticed the “>” was omitted. What is the purpose of the greater than sign? Perhaps I overlooked but it but I don’t see it’s purpose documented anywhere?
How does this
$('#form1-toggle1 input').is(':checked')…differ from
$('#form1-toggle1 > input').is(':checked')It’s all a learning experience…
October 16, 2013 at 6:46 pm #343432
support-octavioMemberHi aviator21114,
I followed up with you on this other checkbox thread:
http://www.genuitec.com/support-genuitec/viewtopic.php?p=21219#p21219Do you still have problems with checkboxes snippets?
-
AuthorPosts
