Solved

remove value from the running list using jquery

Posted on 2012-03-21
3
197 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
  • 2
3 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 435 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Then my code is
 $("#" + newrID).val(list.replace(","+ID2,""));

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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, …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…
The viewer will learn how to dynamically set the form action using jQuery.

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now