javascript - Option not selecting automatically when going back -


i apologize if has been answered. i'm still kind of learning go. have searched , been unable find solution works me. had found one:

firefox ignores option selected="selected"

but adding autocomplete="off" did not work me.

users should able choose option, submit, , when go have selected option available. working in safari, chrome, , opera not working in firefox or ie. select works fine, doesn't automatically select choice when go back.

i have select on same page doesn't appear have same issue.

here html:

<div class="col-sm-2 col-md-2">     <div class="form-group">     <label for="custom_1_units">units</label>         <select class="form-control" id="custom_1_units" name="custom_1_units" value="<?php echo"_session['custom']['custom_1_units'];" ?>" autocomplete="off">             <option value="pages">pages</option>             <option value="lessons">lessons</option>             <option value="activities">activities</option>             <option value="units">units</option>             <option value="projects">projects</option>         </select>     </div>   </div> 

and here php/javascript. it's on .php file:

<?php echo "var cus_1_units ='" . $_session['custom']['custom_1_units'] . "';"; ?>  $("#custom_1_units").each(function() { if($(this).text() == cus_1_units) {     $(this).attr('selected', 'selected');                 }                         }); 

the desired option not selected because loop incorrect. loops through element(?), think want loop through children. change loop following:

$("#custom_1_units").children("option").each(function() { 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -