Hey guys,
I'm new in html and php so, sorry if my question seems clear and easy! Anyway, In my table I've a problem with dynamic Buttons! I'm trying to create a dynamic buttons each with same id+1 (starting from id 1) and I want to sent the data from also dynamic textfield to my database! Knowing that I'm using javascript to generate these buttons and fields and jQuery to parse the data to .php file (if there is easiest way please help me!).
Here is a part of my code..
using javascript i generate a button:
var cell8 = row.insertCell(8);
var itAd = document.createElement('input');
itAd.setAttribute('type', 'submit');
itAd.setAttribute('name', INPUT_NAME_PREFIX + iteration);
itAd.style.width = "100%";
itAd.setAttribute('value', "Add");
itAd.id="add"+iteration;
itAd.setAttribute('onclick', 'addRowToTable()');
$(document).ready(function(){
$("div#msgbox").hide();
$("#add".iteration).click(function() {
$.post('insert.php', {
proid: $("#proid".iteration).val(),
brand: $("#brand".iteration).val()
},
function(response){
$("div#msgbox #msg").html("Item added successfully..");
$("div#msgbox").hide().slideDown("normal");
}
);
return false;
});
$("div#msgbox").click(function(){
$(this).slideUp("normal");
})
});
The HTML code is:
<table border=1 id="item_Table" width=73%>
<tr>
<th style="width:4%; size:20px;">#</th>
<th style="width:10%; size: 5px">Product ID</th>
<th style="width:10%; size: 5px">Brand</th>
<th style="width:4%"></th>
</tr>
</table>
var cell8 = row.insertCell(8);
var itAd = document.createElement('in
itAd.setAttribute('type', 'submit');
itAd.setAttribute('name', INPUT_NAME_PREFIX + iteration);
itAd.style.width = "100%";
itAd.setAttribute('value',
itAd.id="add"+iteration;
itAd.className = "addButton";
and replace :
$("#add".iteration).click(
by :
$(".addButton").live("clic
more info : http://api.jquery.com/live/