I have a dynamicdrop down, I am fetching options dynamically. Below is the code but option "selected"
is not working in spite of giving it in first HTML tag. I want Select Category to be selected by default on page load.
My PHP code:
<?php $decode = json_decode($str_json_format, TRUE); ?>
<select name="category" id="category" tabindex="6">
<option value="1" selected>Select category</option>
<?php foreach($decode as $key => $value) { ?>
<option value="<?php echo $value['category_id']; ?>"><?php echo $value['name']; ?></option>
<?php } ?>
</select>