Friday, 6 September 2013

how to change the color of the table cells by specified string

how to change the color of the table cells by specified string

I want my table row to change its color depending its dropdown status. How
to do this using ajax?
echo '<table id="table_id">';
echo '<tr>';
echo '<td><b>'.$client.'</b></td>';
echo '<td>
<select class="color_status"
onchange="update_Status(this.value)">
<option value="Red">Red</option>
<option value="Green">Green</option>
<option value="Yellow">Yellow</option>
</select>
</td>';
echo '</tr>';
echo '</table>';
if i will select a red in the dropdown. the current row cell will change
its color. and I did something like this on script.
function update_Status(str){
if(str=='Red'){
//the current row cells will turn to red
}
if(str=='Green'){
//the current row cells will turn to green
}
if(str=='Yellow'){
//the current row cells will turn to yellow
}
}

No comments:

Post a Comment