android - JQM multiselect list option Set value selected from database -


i have created , multi-select list option able store values of data selected , store value in database know want set multi select option selected per values stored in data base. here code of creating , multi select option:

<select name="select-choice-b" id="select-choice-b" class="validate[required]" data-native-menu="false"data-theme="c" multiple>                     <option value="">choose source</option>                     <option value="no source">no source</option>                     <option value="our website">our website</option>                     <option value="word of mouth">word of mouth</option>                     <option value="referral">referral</option>                     <option value="newspaper ad">newspaper ad</option>                     </select> 

here javascript set option selected base on values: here resource contains values:no source,our website

var optionvalue=item['resource'];                             var values=optionvalue.split(",");                             $("#"+element_id).filter('[value='"+values+"']')attr('selected','selected'); 

you need refresh select element when selecting options programatically.

run following after script

$('#select-choice-b').selectmenu('refresh'); 

more info here: (http://jquerymobile.com/demos/1.2.0/docs/forms/selects/methods.html)


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -