?
Solved

remove value from the running list using jquery

Posted on 2012-03-21
3
Medium Priority
?
207 Views
Last Modified: 2012-08-13
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();
0
Comment
Question by:erikTsomik
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 1740 total points
ID: 37748279
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,""))
0
 
LVL 19

Author Comment

by:erikTsomik
ID: 37748315
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(","));
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37748500
Then my code is
 $("#" + newrID).val(list.replace(","+ID2,""));

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

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question