I am having trouble on how will I solve this problem. I want only to refresh the value of listbox after adding a value from textbox using onclick() on an image.
<form id="UpdateDetails">
<input type="hidden" name="id">
<input id="adnew" type="text" autocomplete="off" name="addnew" class="xx">
<img id="img" onclick="addnew()" src="images/icons/add-icon.png" style='padding:0 0 0 10px;height:15px;width:15px;cursor:pointer;' title='Add New' />
<span id="checkStatus"></span><br/>
<select multiple>
<?php
$id=$_POST['id'];
$sq = mysql_query("SELECT testVal FROM x_file WHERE id='$id'");
while($q = mysql_fetch_array($sq)){
echo "<option value=".$q['testVal'].">".$q['testVal']."</option>"; }
?>
</select>
</form>
<script>
function addnew(){
$.ajax({
type: 'post',
url: 'addnew.php',
data: $('#UpdateDetails').serialize(),
success: function (info) {
$('#checkStatus').fadeIn(250).css('color', '#017c04').html(info).delay(1000).fadeOut(500);
clearInput();
}
});
}
</script>