i am using the code bellow to grab some data from my db. Also the code bellow delete records from mysql through ajax call. As you can see for each input field i have a save button and a delete button. I am sending a unique id from each record through the a href.
Now all i want is to pass a custom variable to the a href for my save button. And i mean in each a href i added the value cvalue="".
How is it possible to grab the input value from and append it into this cvalue= "in here i want the value from the input field"
Keep in mind that i have a lot records..
<ol class="update">
<?php
$ss = mysql_query ("SELECT * FROM users_channels WHERE u_id='$uid'");
while($chann = mysql_fetch_assoc($ss)) {
echo'
<li>
<input name="channelName" type="text" id="channelName" style="float:left; width:300px; border:1px solid #CCC;" value="'.$chann['channel_name'].'" />
<a href="#" id="'.$chann['id'].'" class="delete_button"><span id="rcolor">Delete</span></a>
<a href="#" id="'.$chann['id'].'" cvalue="'.$chann['channel_name'].'" class="save_button"><span id="gcolor">Save</span></a>
</li>';
}
?>
</ol>
And the Jquery Code:
$(document).ready(function() {
$(function() {
$(".save_button").click(function() {
var id = $(this).attr("id");
var cvalue = $("#channelName").val();
var dataStringe = 'id='+ id + '&cvalue='+ cvalue;
var parent = $(this).parent();
alert(curval);
$.ajax({
type: "POST",
url: "update_channel.php",
data: dataStringe,
cache: false,
beforeSend: function()
{
parent.animate({'backgroundColor':'#fb6c6c'},300).animate({ opacity: 0.35 }, "slow");
},
success: function()
{
//parent.slideUp('slow', function() {$(this).remove();});
}
});
return false;
});
});
});