For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub
- This topic has 10 replies, 2 voices, and was last updated 12 years, 5 months ago by
support-octavio.
-
AuthorPosts
-
Robert GardnerParticipantI have a checkbox widget in my app. I’m having difficulty testing it. Code is pretty simple.
if (progname == 'Elite' && $('#m1-QQ_PeakTravel > input').is(':checked')) {alert('test checkbox true')};I know the test for the progname works by itself. Have I constructed the compound conditional correctly? Also what about the format of my test for the checkbox?
I’ve included the properties for the checkbox widget for review if necessary but I don’t see anything special there.
See attachment Checkbox widget.PNG
Thanks,
Attachments:
You must be logged in to view attached files.October 13, 2013 at 10:54 am #343312
Robert GardnerParticipantI forgot to indicate that I’m running the latest milestone and running the app on an iPad running iOS7 (7.0.2)
See attachment Mobi version screen.PNG
Attachments:
You must be logged in to view attached files.October 14, 2013 at 11:27 am #343330
Robert GardnerParticipantHelp I’m stuck on this one! I’m sure it’s a simple overlook of something… Can someone post a suggestion or resolution?
Thanks.
October 14, 2013 at 12:30 pm #343334
support-octavioMemberHi aviator21114,
The code looks to be OK. The problem might be the comparison of the progname var, have you tried omitting it to isolate that the problem is not with the checkbox code?
if($('#m1-QQ_PeakTravel > input').is(':checked')) {alert('test checkbox true')};I’ve tried your code and it worked well for me assigning “Elite” value to progname var. Let me know if you need further assistance.
October 14, 2013 at 12:46 pm #343335
Robert GardnerParticipantI’ve tried the checkbox code by itself and it does not seem to work.. Let me stare at it again for a few minutes and see if something sticks out..
Nope didn’t work…Copied and pasted what you posted (just to be sure)…. Let me also state that I’m not using the “on change” associated with the checkbox widget. I have a push button that executes the javascript to test the value of the checkbox… is this the issue?
See attachment checkbox push.PNG
See attachment Pushbutton prop.PNG
Attachments:
You must be logged in to view attached files.October 14, 2013 at 1:15 pm #343336
support-octavioMemberHi,
Please take a look at next sample file and use it as a baseline to develop your code. Note that I already set the default value of textfield as “Elite” as your code, so it check if textfield contains this value and checkbox is checked, if yes, fire the alert, if not, it fire an error alert.
If the problem continues let me know where are you testing your app (Test Center, Web Simulator, Device) If device share model and OS.
Attachments:
You must be logged in to view attached files.October 14, 2013 at 1:27 pm #343338
Robert GardnerParticipantAfter seeing how you constructed the widget data format I now quickly see the error….
$('#m1-[b]DistanceCalc[/b]-QQ_PeakTravel > input').is(':checked')<!-- method-1 --> $('#form1-checkbox1 > input').is(':checked')I did not include the filename (form name) in the code construct. I was confused by the example thinking #m1 is the form.
Thanks for your help. That won’t happen again for sure 🙂
October 14, 2013 at 3:50 pm #343340
support-octavioMemberHi aviator21114,
Glad that the example was helpful for you. Thread closed.
October 14, 2013 at 8:16 pm #343350
Robert GardnerParticipantWell, I’m testing variations of using the checkbox value… Why is it when I place the value of the checkbox into a variable it always says ON regardless of whether the box is checked or not?
October 15, 2013 at 8:17 am #343355
Robert GardnerParticipantIs it possible to negate a test of the checkbox value?
if !($('#m1-DistanceCalc-QQ_PeakTravel > input').is(':checked')) {alert('test checkbox not set')};(this doesn’t seem to work)
Apologies if I should be posting these in a new thread… I thought since they are still along the same subject lines I should continue here. Let me know for future reference.
Thanks,
October 15, 2013 at 10:36 am #343365
support-octavioMemberHi aviator21114,
>Is it possible to negate a test of the checkbox value?
Yes, it is. You can either set the exclamation mark after the parenthesis or use an else sentence.if(!$(‘#m1-DistanceCalc-QQ_PeakTravel > input’).is(‘:checked’)){
alert(‘test checkbox false’)
}if($(‘#m1-DistanceCalc-QQ_PeakTravel > input’).is(‘:checked’)){
alert(‘test checkbox true’)
}
else{
alert(‘test checkbox false’)
}>Why is it when I place the value of the checkbox into a variable it always says ON regardless of whether the box is checked or not?
Do you still have this issue? Can you share where are you testing it? Test Center, Web SIM, Device?(If device, please share model and OS)>Apologies if I should be posting these in a new thread…
There is not a problem. -
AuthorPosts
