php - Bootstrap DropDown Autoselect -
i'm using bootstrap dropdown enhancement, there way can pre-select 1 of dropdown options based on value pulled database? i've tried following works normal radio buttons isn't working this. i'm guessing because it's bootstrap it'll need sort of .active or .selected adding in somewhere.
<!-- email --> <div class="form-group"> <label for="pri_email" class="col-sm-3 control-label">primary email</label> <div class="col-sm-9"> <div class="input-group"> <input type="email" class="form-control" id="pri_email" placeholder="email" name="pri_email" value="<?php echo $row_showcontact[0]['pri_email'];?>"> <div class="btn-group input-group-btn"> <button data-toggle="dropdown" class="btn btn-default dropdown-toggle">home <span class="caret" style="margin-left: 4px"></span></button> <ul class="dropdown-menu"> <li><input type="radio" id="pri_email_home" name="pri_email_type" value="home" <?php if (!(strcmp("home", $row_showcontact[0]['pri_email_type']))) {echo "checked=\"checked\"";} ?>><label for="pri_email_home">home</label></li> <li><input type="radio" id="pri_email_work" name="pri_email_type" value="work" <?php if (!(strcmp("work", $row_showcontact[0]['pri_email_type']))) {echo "checked=\"checked\"";} ?>><label for="pri_email_work">work</label></li> <li><input type="radio" id="pri_email_marketing" name="pri_email_type" value="marketing" <?php if (!(strcmp("marketing ", $row_showcontact[0]['pri_email_type']))) {echo "checked=\"checked\"";} ?>><label for="pri_email_marketing">marketing</label></li> <li><input type="radio" id="pri_email_invoice" name="pri_email_type" value="invoice" <?php if (!(strcmp("invoice", $row_showcontact[0]['pri_email_type']))) {echo "checked=\"checked\"";} ?>><label for="pri_email_invoice" >invoice</label></li> </ul> </div> </div> </div> </div>
the drop down in general works fine, , value
of pri_email_type
being stored in database okay - want able re-call it.
thanks.
i solved myself, above code changed this...
<button data-toggle="dropdown" class="btn btn-default dropdown-toggle">home <span class="caret" style="margin-left: 4px"></span></button>
to this...
<button data-toggle="dropdown" class="btn btn-default dropdown-toggle"><?php if($row_showcontact[0]['pri_email_type'] == ""){echo "home";}else{echo ucfirst($row_showcontact[0]['pri_email_type']);}?> <span class="caret" style="margin-left: 4px"></span></button>
Comments
Post a Comment