Link to home
Start Free TrialLog in
Avatar of erikTsomik
erikTsomikFlag for United States of America

asked on

remove value from the running list using jquery

I have a 2 running list that a stored in the hidden form variable. 1 is to keep selected items another is to keep deleted items. When i click on delete icon i need to remove the item from the first list and add it to the second list. Addition piece is working .

I have a code for deletion  but it does not work

var newrID = 'r' + ID;
                  var list = $('#' + newrID).val();
                  var index = list.indexOf(ID2);
                  alert(list);
                  alert(list.indexOf(bodyID));
                  $("#" + newrID).val(list).find(ID2).remove();
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of erikTsomik

ASKER

My Add is here

var newdID = 'd' + ID;
                  var curr_relID = $("#" + newdID).val();
                  curr_relID = curr_relID.split(",");
                  curr_relID.push(ID2);
                  $("#" + newdID).val(curr_relID.join(","));
Then my code is
 $("#" + newrID).val(list.replace(","+ID2,""));

Or split, loop and delete item then join if array not empty