Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function disegnatabelleIngr() {
- ...
- for (var i = 0; i < Math.max(arrayIngrOK.length, arrayIngrKO.length); i++) {
- //tabOK is the id of an html table that i have to build dinamically
- rok = tabOK.append("tr");
- rok.append("td");
- //in arrayIngrOK[i] there is a name of a ingredient that the user can insert with the input text (see more).
- rok.append("td").text(arrayIngrOK[i]);
- /*whit the field Rimuovi i want to eliminate the specific element of an array. For esample, if one user have inserted 2 elements, in the table i see
- eggs Rimuovi....
- chicken Rimuovi....
- pepper Rimuovi....
- milk Rimuovi....
- if i click on the text Rimuovi near the name "pepper" i want to remove the element pepper, but with this code the element that will be eliminated is always the last inserted, so, in this case, will be the element milk.*/
- rok.append("td")..text("Rimuovi...").on("click", function(){
- arrayIngrOK.splice(i-1,1);
- disegnatabelleIngr();
- });
- rok = tabOK.append("tr");
- rok.append("td").append("img").attr("src", "imm/happy.png");
- rok.append("td").append("input").attr("type","text").attr("id", "inputOK");
- rok.append("td").text("Aggiungi...").on("click", function() {
- if(document.getElementById("inputOK").value != "" && document.getElementById("inputOK").value != null)
- AggiungiIngrOK();
- });
- function AggiungiIngrOK(){
- arrayIngrOK[arrayIngrOK.length]=document.getElementById("inputOK").value;
- disegnatabelleIngr();
- }
Add Comment
Please, Sign In to add comment