i got correct saveID but TemplateData and TitleData it only copy first row data even i change to something else. saveID is unique id of the data. what i need is when i changed it capture the data not first column data.
<script type="text/javascript">
$(document).ready(function() {
$(".save_button").click(function (e) {
e.preventDefault();
var saveID =$(this).val();
var url_tna = "<?php echo $_SESSION['url_address'];?>mods/agent_management/code/";
var TitleData =$("#TitleData").val(); //build a post data structure
var TemplateData =$("#TemplateData").val();
var IdData =$("#IdData").val();
alert(saveID);
alert(TemplateData);
alert(TitleData);
var JsonData = {TitleData: TitleData, TemplateData: TemplateData, saveID: saveID};
jQuery.ajax({
type: "POST", // Post Get method
url: url_tna+"email_template_response.php", //Where form data is sent on submission
dataType:"text", // Data type, HTML, json etc.
data:JsonData, //Form variables
success:function(response){
window.location.reload(true); // reload before append
$("#responds").append(response);
document.getElementById("contentText").value = "";
},
error:function (xhr, ajaxOptions, thrownError){
alert(thrownError);
}
});
});
});
</script>
<table>
<tr>
<td>No</td>
<td>Title</td>
<td>Template</td>
<td>Recipents</td>
<td>Schedule</td>
</tr>
<?php $i=1; while ($row = mysql_fetch_array($result)) { ?>
<tr>
<td><?php echo $i; ?></td>
<td><textarea type="textarea" id="TitleData" name="TitleData" class="1"><?php echo $row['title'];?></textarea></td>
<td><textarea type="textarea" id="TemplateData" name="TemplateData" class="1"><?php echo $row['template'];?></textarea></td>
<td><button id="recipant"><a id="myLink" href="email_template.php?id=<?php echo $row['id']; ;?>" target="_blank">Open Recipant</a> </button></td>
<td><button id="shedule"><a id="myLink" href="email_schedule.php?id=<?php echo $row['id']; ;?>" target="_blank">Open Shedule</a></button></td>
<td><input type="hidden" id="IdData" class="save_button1" name="txtLink" value="<?php echo $row['id']; ?>"></input></td>
<td><button id="SaveTemplate" name="SaveTemplate" class="save_button" value="<?php echo $row['id'];?>"><a href="#" style="display:block" class="button insertcolumn" id="<?php echo $row['id'];?>">Save</a></button></td>
<td><button >Sent Mail Now</button></td>
</tr>
<? $i++; }?>
</table>
if (!empty($saveID)) {
$sql2 = "UPDATE at_agent_template set title = '$TitleData', template= '$TemplateData' where id = '$saveID'";
$result2 = mysql_query($sql2);
}