• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 212
  • Last Modified:

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);
                  $("#" + newrID).val(list).find(ID2).remove();
  • 2
1 Solution
Michel PlungjanIT ExpertCommented:
You are assuming list is a jQuery object. It is just a string.

You did not show you add so I cannot see if you use commas or what.

Perhaps you mean this:

 $("#" + newrID).val(list.replace(ID2,""))
erikTsomikSystem Architect, CF programmer Author Commented:
My Add is here

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

Or split, loop and delete item then join if array not empty
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now