First timer here, first try at php/jquery
this code is working:
$('#update1').click(function(){
var name= $('#bandname-1').val();
var bandid = $('#bid-1').val();
var mbid = $('#mbid-1').val();
$('#msg').text('updating...');
$.post('func/update_bandname.php',{
name: name,
bandid: bandid,
mbid: mbid
}, function(data){
$('#msg1').text(data);
});
});
this is my php:
-snip
echo "<td>";
echo "<input type=\"text\" name=\"bandname-".$i."\" id=\"bandname-".$i."\" value=\"".$name ."\"/> ";
echo "<input id=\"update".$i."\" type=\"button\" name=\"update".$i."\" value=\"update\" class=\"dp\"/>";
echo "<span id=\"msg".$i."\"></span><input type=hidden id=\"bid-".$i."\" value=\"".$_REQUEST[bid] ."\" name=bid-".$i."\" />";
echo "<input type=hidden id=\"mbid-".$i."\" value=\"".$bandid."\" name=mbid-".$i."\" />";
echo "</td>";
echo "</tr>";
$i++;
the DB returs alot of records into this table, and i created 5 functions update1,update2,etc
is there a way to modify my jquery to pass different id values to one function? instead of copying the function over and over again?
Thanks
Assign a common class and
data-attribute to each element:PHP:
JS: