Solved

my append to the list

Posted on 2014-03-26
11
245 Views
Last Modified: 2014-03-26
hi,


How can I remove "URMBT? ;?Auto" from my select

 $('#DispSelectedGroupBox').append('<option value="' + companyname + '";"' + companytext + '" data-companyname="' + companytext + '">' + companytext + '</option>');

something like this: 

 $('#DispSelectedGroupBox').append('<option value="' + companyname + '";"' + companytext + '" data-companyname="' + companytext  + '">' + '</option>');
						 

Open in new window


How can I remove "URMBT? ;?Auto" from my select

<SELECT style="BACKGROUND-COLOR: #f8fafc; WIDTH: 250px; HEIGHT: 100px" id=DispSelectedGroupBox class=SearchBySelect5 multiple size=180 name=DispSelectedGroupBox>

<OPTION value="4;Auto / URMBT" data-companyname="Auto / URMBT" URMBT? ;?Auto>Auto / URMBT</OPTION>

<OPTION selected value="2;A &amp; A DRIVING SCHOOL" data-Companyname="A &amp; A DRIVING SCHOOL">A &amp; A DRIVING SCHOOL</OPTION></SELECT>

Open in new window

0
Comment
Question by:lulu50
  • 6
  • 5
11 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 39956862
Test page : http://jsfiddle.net/r9LmN/

var whatToRemove="Auto / URMBT";
$("#DispSelectedGroupBox option[data-companyname='" + whatToRemove + "']").remove();

Open in new window

0
 
LVL 82

Expert Comment

by:leakim971
ID: 39956872
work too : http://jsfiddle.net/r9LmN/2/

$("#DispSelectedGroupBox option").filter(function() { return $(this).val().indexOf("4")==0; }).remove();

Open in new window

0
 

Author Comment

by:lulu50
ID: 39956873
leakim971,

the append works but I don't need two companytext at the end
I just need the value and the data-companyname

so,

value = companyname ; companytext
data-companyname= companytext

 $('#DispSelectedGroupBox').append('<option value="' + companyname + '";"' + companytext + '" data-companyname="' + companytext + '">' + companytext + '</option>');

I need to take out this extra companytext at the end.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 82

Expert Comment

by:leakim971
ID: 39956885
Not sure... Try this :

 $('#DispSelectedGroupBox').append('<option value="' + companyname + '";"' + companytext + '">' + companytext + '</option>'); 

Open in new window

0
 

Author Comment

by:lulu50
ID: 39956889
I want just to take out this extra companytext so I need something like this
but I have an error

 $('#DispSelectedGroupBox').append('<option value="' + companyname + '";"' + companytext + '" data-companyname="' + companytext + '">' + '</option>');
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 39956905
Please write the option yoiu want without the code

The following is valid but don't display anything in the option text :
$('#DispSelectedGroupBox').append('<option value="' + companyname + ';' + companytext + '" data-companyname="' + companytext + '">' + '</option>');

Open in new window


With the option text :
$('#DispSelectedGroupBox').append('<option value="' + companyname + ';' + companytext + '" data-companyname="' + companytext + '">' + companytext + '</option>');

Open in new window


Good too:
$('#DispSelectedGroupBox').append('<option value="' + companyname + '" data-companyname="' + companytext + '">' + '</option>');

Open in new window

and :
$('#DispSelectedGroupBox').append('<option value="' + companyname + '" data-companyname="' + companytext + '">'  + companytext + '</option>');

Open in new window

0
 

Author Comment

by:lulu50
ID: 39956908
cc
0
 
LVL 82

Expert Comment

by:leakim971
ID: 39956914
your attributes must have quote at the beggining and at the end
0
 

Author Comment

by:lulu50
ID: 39956925
$('#DispSelectedGroupBox').append('<option value="' + companyname + ';' + companytext + '" data-companyname="' + companytext + '">' + companytext + '</option>');	

Open in new window


c
0
 
LVL 82

Expert Comment

by:leakim971
ID: 39956933
remove company text, check my two last propositions
0
 

Author Closing Comment

by:lulu50
ID: 39956942
Excellent,  

Thank you ++++++
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

821 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