In the below code i have an array arrSGoal. On Click of RemoveGoal i need to delete or set the value to 0 for the the id in the array.
Array is in php. dont know how to use in the jquery.
<SCRIPT LANGUAGE="JavaScript">
$(document).ready(function() {
$('a.removegoal').click(function(e)
{
e.preventDefault();
//Getting the TR to remove it in case of successful deletion
var objRow = $(this).closest('tr');
objRow.remove();
});
});
$arrSGoal[$i] = $row->id_goals;
?>
<tr>
<td style='vertical-align:top;'>
<textarea name="stg<?php print $i;?>" id="short_goal" class="short_go"><?php print $row->goal_description?></textarea>
</td>
< td style=’vertical-align:bottom;’ nowrap> <span class=’hidden’> echo $i </span> <a href=# class=”removegoal” >Remove Goal
I don’t understand your code, but a good way to “export” an array from PHP into Javascript is json_encode().
At any rate, you need to be aware that PHP is executed server side, and Javascript on the client side. There is no way to directly interact between the PHP code and Javascript, e.g. to do a calculation in JQuery and have PHP work with the result. (Well, without AJAX, that is).