Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

remove value from the running list using jquery

Posted on 2012-03-21
3
Medium Priority
?
208 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 October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. 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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

618 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