- This topic has 7 replies, 2 voices, and was last updated 11 years, 1 month ago by hussain.m.
-
AuthorPosts
-
hussain.mMemberHi,
I want to dynamically select from one of the options in my select list when a button is clicked. I also want the new option selected in the select list menu to be displayed on the screen. So the old label should not be shown as selected anymore after button is pressed. Instead, the new label shown be shown.
I can retrieve the value of the current selection by:
var selection1 = $(‘select[name=”selectListMenu1″]’).val();But what is the code for setting a different value and displaying the corresponding label for it on the screen?
Please let me with the JavaScript code for this.
Thank you.
hussain.mMemberPlease can anyone help? It’s urgent.
Thank you.
support-octavioMemberHi hussain.m,
You can achieve it creating the next function in your custom.js file.
function selectItem(item){ var selListId = 'm1-testSelect-list1'; var listName = 'list1'; var itemToSelect = item; var selId = $('#' + selListId + '> li').each( function (i) { $(this)[i == itemToSelect ? 'addClass' : 'removeClass'](m1Design.css("selected")); }); // This line updates hidden select, for the case the whole // design will be used as a form phoneui.preprocessDOM('#' + selListId); }
Then, call it in your button sending the parameter of the item you want to select:
selectItem(1);
Note that first item in list will be 0, so, with this example you’ll be selecting the second item on the list.
hussain.mMemberI tried your code but it is not working. When I press the button, nothing happens.
I am using Select List Menu with List Display Mode set as Spinner.I plugged in my variable as below:
var selListId = ‘m1-Untitled1-list1’;
var listName = ‘selectListMenu1’;Please let me know how to fix this.
Thank you.
support-octavioMemberHi hussain.m,
Disregard my last reply, I thought you were looking select an item in a select list item. Please take a look at next sample file that meet the requirement you have requested.
Attachments:
You must be logged in to view attached files.
hussain.mMemberThanks for your reply.
This code works for the Select List Menu when the ‘Item Display Mode’ is set to “Select List”. It does not work when I change it to “Spinner”. Can you send me code for “Spinner” Item Display Mode??
support-octavioMemberHi hussain.m,
Seems that the third try is the good one. See attached example.
Attachments:
You must be logged in to view attached files.
hussain.mMemberWorks perfectly! 🙂
Thank you. -
AuthorPosts