I have a drop down list
<div class="col-lg-8">
<select class="form-control" id="question_type" name="agreement[question_type]">
<option value="">Select Type</option>
<option value="ss">Single select (checkbox)</option>
<option value="ms">Multi option (radio)</option>
</select>
</div>
After submitting the form I have placed this datas in table ,
<tr data-view-key="<?php echo $jagr_id; ?>">
<td class="question_type">
<?php
if ($jagr_question_type == 'ss') {
echo 'Single select (checkbox)';
} else if ($jagr_question_type == 'ms') {
echo 'Multi option (radio)';
}
?>
</td>
<td><a href="#<?php echo $jagr_id; ?>" name="edit_agreement" ><span class="glyphicon glyphicon-edit" title="Edit"></span></a> <a href="#<?php echo $jagr_id; ?>" name="delete_agreement" ><span class="glyphicon glyphicon-trash" title="Delete"></span></a></td>
</tr>
and on the edit button click,i want to display the selected item in drop down list. following code is used for edit click
$(document).on("click", "a[name = 'edit_agreement']", function(event)
{
event.preventDefault();
var jagr_id = $(this).attr("href").substring(1);
var parent = $(this).parents("[data-view-key='"+jagr_id+"']");
var question_type = parent.find("td.question_type").text();
$("#hdn_jagr_id").val(jagr_id);
$("#question_type option:selected").text(question_type);
});
using $("#question_type option:selected").text(question_type); i can display the text in the drop down list, but again submit the form the value not posted, Now the html part changed like this(repeating th eselected item)
<div class="col-lg-8">
<select class="form-control" id="question_type" name="agreement[question_type]">
<option value>Single select (checkbox)//selected item</option>
<option value="ss">Single select (checkbox)</option>
<option value="ms">Multi option (radio)</option>
</select>
</div>