(I) always live on the server-side of life

More posting as a reminder to myself to save looking up on the Stack when I need reminding again.

== To capture the value of an selected select form item,
var c = $(“#object_id option:selected”).val();

== To capture the option text of an selected select form item,
var t = $(“#object_id option:selected”).text();

== To dynamically add an option to a select list,
$(“#object_id”).append($(”).val(‘value’).html(‘option text’));

== To mark a specific option in a list as selected,
$(“#object_id”).val(value).attr(‘selected’, ‘selected’);

or

$(“#phone_archiving_policy_id option[value='”+value+”‘]”).attr(‘selected’, ‘selected’);

Would like to say that I’d figured this out myself but while JavaScript (and particularly JQuery) enable some very impressive effects I still prefer the server-side of life and defer to those on fora to advise on dynamic visual features; web design just kills me.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s