For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub
- This topic has 8 replies, 2 voices, and was last updated 12 years, 7 months ago by
support-octavio.
-
AuthorPosts
-
dannyg280MemberI am a new MobiOne user and have limited javascript experience. So hopfully this a simple question:
I have 2 Comboboxes, one called Category (cat) and one called Sub Category (subcat). I want the Sub Category box’s values to populate depending on which value is chosen in the Category box. I thought I had my code right but when I run it in Test Center, I must choose a category twice for it to work. In other words, nothing polulates in the Sub Category Box the first time I choose a category. Here is my code, which I entered into the “On Change…Run Javascript” action of the Category combobox:
$category = $("select[name='cat']"); $subcat = $("select[name='subcat']"); $category.change(function() { if ($(this).val() == "FC") { $("select[name='subcat'] option").remove(); $("<option>Neutral Floor Cleaner</option>").appendTo($subcat); $("<option>Heavy Duty Floor Cleaner</option>").appendTo($subcat); $("<option>Degreaser</option>").appendTo($subcat); } if ($(this).val() == "SC") { $("select[name='subcat'] option").remove(); $("<option>All Purpose Cleaner</option>").appendTo($subcat); $("<option>HD Spray Cleaner</option>").appendTo($subcat); $("<option>Peroxide Cleaner</option>").appendTo($subcat); } if ($(this).val() == "DIS") { $("select[name='subcat'] option").remove(); $("<option>Neutral Disinfectant</option>").appendTo($subcat); $("<option>Alkaline Disinfectant</option>").appendTo($subcat); $("<option>Frag-Free Disinfectant</option>").appendTo($subcat); } });Any help would be greatly appreciated!
August 15, 2013 at 1:47 pm #341509
support-octavioMemberHi dannyg280,
You can try calling the phoneui.preprocessDOM after populating your combobox to refresh the data:
phoneui.preprocessDOM('#m1-<screenID>');or
phoneui.preprocessDOM(phoneui.getCurrentPageId());You can also take a look at this example provided by dev team that demonstrate how to populate a combobox: http://portal.genuitec.com/support-genuitec/viewtopic.php?p=18229#p18229
And here is another topic where a similar question was responded: http://www.genuitec.com/support-genuitec/viewtopic.php?p=12785#p12785
August 15, 2013 at 2:47 pm #341511
dannyg280MemberThank you so much for your response. I apologize for being so new at this but I can’t seem to get either of those options to work. I’m attaching my MobiOne files hoping you can tell me where I went wrong. I feel like I must not be calling the correct screenID? I’m not sure.
Attachments:
You must be logged in to view attached files.August 15, 2013 at 7:02 pm #341529
support-octavioMemberHi dannyg280,
Seems that the problem wasn’t that the use of phoneui.preprocessDOM() function. In the code you don’t need to add the event, since it’s being created by Mobione, please try next code:
$subcat = $("select[name='subcat']"); if ($(this).val() == "FC") { $("select[name='subcat'] option").remove(); $("<option>Neutral Floor Cleaner</option>").appendTo($subcat); $("<option>Heavy Duty Floor Cleaner</option>").appendTo($subcat); $("<option>Degreaser</option>").appendTo($subcat); } if ($(this).val() == "SC") { $("select[name='subcat'] option").remove(); $("<option>All Purpose Cleaner</option>").appendTo($subcat); $("<option>HD Spray Cleaner</option>").appendTo($subcat); $("<option>Peroxide Cleaner</option>").appendTo($subcat); } if ($(this).val() == "DIS") { $("select[name='subcat'] option").remove(); $("<option>Neutral Disinfectant</option>").appendTo($subcat); $("<option>Alkaline Disinfectant</option>").appendTo($subcat); $("<option>Frag-Free Disinfectant</option>").appendTo($subcat); } phoneui.preprocessDOM('#m1-GCC');Let us know how it goes.
August 16, 2013 at 7:29 am #341543
dannyg280MemberOctavio- Thank you!! Worked perfectly! I’m now on my 2nd day of my MobiOne trial and I’m loving it! To get free, helpful support without criticism on a newbie question is almost unheard of. I almost certainly will be purchasing a license and be recommending it to friends.
Thanks Again
Dan
August 16, 2013 at 9:19 am #341549
dannyg280MemberOne more quick question. That works great and if I understand it right, it will populate the Combobox with options with no values… Can you tell me the correct syntax to have it populate both an option and a value? I tried the code below but it doesn’t seem to be working, it actually breaks the original code and the box does not populate at all.
$("<option value="NFC">Neutral Floor Cleaner</option>").appendTo($subcat);August 16, 2013 at 11:41 am #341555
support-octavioMemberHi,
I followed the example I shared in a previous post, and with this code, it works fine:
$("<option />").val("Neutral Floor Cleaner").text("Neutral Floor Cleaner").appendTo($subcat);August 16, 2013 at 1:59 pm #341561
dannyg280MemberOnce again, thank you! Worked perfectly!
August 16, 2013 at 2:28 pm #341564
support-octavioMemberHi dannyg280,
Thanks for the follow up. Glad to help. Marking thread as closed.
-
AuthorPosts
