John Cook
Posts: 0
Joined: Wed Mar 05, 2014 9:46 pm

How to Update default (selected) value in list via jquery or javascript?

I want to set or update the the default selection of a LIST component via javascript. How can i achieve this w/ appery? tried this $('select option:contains("it\'s me")').prop('selected',true); but i think something is wrong w/ my syntax in appery?

http://stackoverflow.com/questions/47...

John Cook
Posts: 0
Joined: Wed Mar 05, 2014 9:46 pm

How to Update default (selected) value in list via jquery or javascript?

The code i tried is - $('desired_salary_select option:contains("Between 75000 and 125000")').attr("selected",true);

where desired_salary_select is the name of my list UI component and "Between 75000 and 125000" is one of the options.

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

How to Update default (selected) value in list via jquery or javascript?

Following code should help:

pre
code
Appery("mobileselectmenu_30").val("Vici").trigger("change");
/code
/pre
where: "mobileselectmenu_30" - select menu component name.
and "Vici" - is desire value.

John Cook
Posts: 0
Joined: Wed Mar 05, 2014 9:46 pm

How to Update default (selected) value in list via jquery or javascript?

you're the man igor. It works :
;
Appery("desired_salary_select").val("Between 50000 and 75000").trigger("change");

Note i also tried - $('div[dsid="desired_salary_select"]').val("Between 50000 and 75000").trigger("change"); but that didnt work, any guess why? I double checked the html and that is the correct dsid

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

How to Update default (selected) value in list via jquery or javascript?

You are using:
pre
code
$('div[dsid="desired_salary_select"]').val("Between 50000 and 75000").trigger("change")
/code
/pre
This jQuery selector could get only "div" element. But you should get "select" html element.

Return to “Issues”