Only the first row is updating.. I was able to create a dynamically created select tags and button but every time I were to choose to the drop down, only the first row is being updated and the other rows will alert only "choose first" even though i already selected an option.
jquery func'
$('input').each(function(){
if($(this).attr("type")=="button"){
$(this).click(function{
var empid=$('#emp').val();
var job=$('#jobselect').val();
if(job !== "NULL"){
$.ajax({
type:"POST",
url:"<?php echo base_url(); ?>userskills/update",
data:{'Emp_ID':empid,'Job':job},
cache: false;
success:
function(data){
alert("Updated!");
}
});
}else{
alert("Choose first");
}
});
}
});
this is my tbody in the table
<tbody>
<?php foreach($job as $temp): ?>
<tr>
<td><?php echo $temp->Name?></td>
<td><?php echo $temp->Group?></td>
<td><?php echo $temp->Section?></td>
<td>
<select id="jobselect">
<?php foreach($roles as $role): ?>
<option value="<?php echo $role->RoleID">"><?php echo $role->RoleName?></option>
<?php endforeach; ?>
</select>
<input type="hidden" id="emp" value="<?php echo $temp->JobID?>" />
<input type="button" id="update"/>
</td>
</tr>
<?php endforeach; ?>
</tbody>