Ignacio Valdés
Posts: 0
Joined: Wed Dec 11, 2013 7:21 pm

Select component

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!

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Select component

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

Ignacio Valdés
Posts: 0
Joined: Wed Dec 11, 2013 7:21 pm

Select component

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

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

Ignacio Valdés
Posts: 0
Joined: Wed Dec 11, 2013 7:21 pm

Select component

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

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Select component

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.

Cody Blue
Posts: 0
Joined: Sun Aug 25, 2013 2:11 am

Select component

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.

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

Select component

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

Cody Blue
Posts: 0
Joined: Sun Aug 25, 2013 2:11 am

Select component

It does! Many thanks.

M&M
Posts: 0
Joined: Tue Nov 11, 2014 6:59 am

Select component

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

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Select component

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...

Return to “Issues”