Page 1 of 1

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

Posted: Tue Mar 18, 2014 12:13 am
by John Cook

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


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

Posted: Tue Mar 18, 2014 12:14 am
by John Cook

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.


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

Posted: Tue Mar 18, 2014 1:21 am
by Igor

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.


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

Posted: Tue Mar 18, 2014 4:25 am
by John Cook

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


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

Posted: Tue Mar 18, 2014 4:52 am
by Igor

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.