I'm using bootstrap dropdown enhancement, is there a way I can pre-select one of the dropdown options based on a value pulled from the database? I've tried the following which works for normal radio buttons but it isn't working for this. I'm guessing because it's bootstrap it'll probably need some 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, and the value
of pri_email_type
is being stored in the database okay - I just want to be able to re-call it.
Thanks.
I solved myself, with the above code as is I changed this...
to this...