Page 1 of 1

How to set the index of menu select with a value?

Posted: Fri Aug 09, 2013 1:02 am
by Brian6028327

I have a menu select that's populated with 5 items. When the page that it's on is loaded, I'd like to start with the menu select on item 3. How do I set it with JS (not with 'set property' in the builder)?
-thanks


How to set the index of menu select with a value?

Posted: Fri Aug 09, 2013 1:11 am
by Alena Prykhodko

Hello Brain!

Can you clear, do you want the third item to be chosen? I'm not sure I understand you correctly.


How to set the index of menu select with a value?

Posted: Fri Aug 09, 2013 4:44 am
by Brian6028327

Hi, yes the third (or whatever) menu choice should be the one that's automatically selected when the page loads (as if the user had selected it).

It'll actually be a local variable, instead of a hard-coded 3. What I'm doing is having the user make a selection on one page then I want that selection to carry through to another page when it loads.


How to set the index of menu select with a value?

Posted: Fri Aug 09, 2013 5:56 am
by Kateryna Grynko

Hi Brian,

Run the following:
codeAppery( "selectmenu_name" ).find( "option:eq(2)" ).attr("selected", "selected");
Appery( "selectmenu_name" ).selectmenu( "refresh" );/code


How to set the index of menu select with a value?

Posted: Sat Aug 10, 2013 9:55 am
by Brian6028327

Thanks! That works perfectly!