Page 1 of 2

Select component

Posted: Wed Feb 05, 2014 7:59 pm
by Ignacio Valdés

I'm a little confused about using the select component.

I need that when user select a option, a different page is displayed for each option.

Image

Thanks!


Select component

Posted: Wed Feb 05, 2014 8:09 pm
by Maryna Brodina

Hello! You have to use Run JS action. Add code which retrieves current Select value and execute necessary action depending on current value.


Select component

Posted: Mon Feb 10, 2014 5:00 pm
by Ignacio Valdés

return {
'field' : data.field '',
'field1' : data.filed1 0,
...
}

Something like that? Sorry but I don't know JavaScript =( Researched as much as I can...


Select component

Posted: Mon Feb 10, 2014 5:12 pm
by Ignacio Valdés

var newPath = $($(Appery("mobileselectmenu_6")).find("option:selected")).attr("value");
Appery('mobileimage_9').refresh();


Select component

Posted: Mon Feb 10, 2014 5:14 pm
by Kateryna Grynko

Hi Ignacio,

Answered directly. Duplicate here.

Create a function in custom JavaScript which accepts parameters that define what function to call. Run this function on 'value change' event.

To get a value of selected component 'select' value run this code:preAppery("mobileselectmenu").find(":selected").val();/prewhere 'mobileselectmenu' is a component name.


Select component

Posted: Tue Feb 25, 2014 5:33 am
by Cody Blue

I have a related, though not exactly the same question.

I want to be able to iterate through and save all the values of drop down elements from select menu to an array.

Array_i = Appery("selectmenu").val_of_option_i;

How may I go about it? If possible to suggest the way to access individual elements in a loop and how to fetch the length to iterate though, that might help?

Thank you.


Select component

Posted: Tue Feb 25, 2014 6:16 am
by Igor

Below code should work:
pre
code
var values = [];

var options = Appery("mobileselectmenu_12").find("option");
for(var i = 0; i < options&#46;length; i++){
var option = jQuery(options);

Code: Select all

 values&#46;push({value: option&#46;val(), view: option&#46;text()}); 

}

&#47;&#47;show array in the browser console
console&#46;log(values);
/code
/pre


Select component

Posted: Tue Feb 25, 2014 5:48 pm
by Cody Blue

It does! Many thanks.


Select component

Posted: Tue Nov 18, 2014 7:43 am
by M&M

hi

Your code

var values = [];
var options = Appery("mobileselectmenu_12").find("option");
for(var i = 0; i < options.length; i++){
var option = jQuery(options);
values.push({value: option.val(), view: option.text()});
}
//show array in the browser console
console.log(values);

works but then I see this at the end

7: Objectvalue: ""view: "↵

Shouldn't it be options.length - 1?

Thanks,
M&M


Select component

Posted: Tue Nov 18, 2014 8:19 am
by Evgene Karachevtsev

Murali,

No, there shouldn't be options.length - 1
Because the condition is
prei < options&#46;length/pre
not
prei /pre
Please inspect the element. look what options there are in select and you'll see if everything works correctly or not. http://devcenter.appery.io/documentat...