Solved

my append to the list

Posted on 2014-03-26
11
243 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

DevOps Toolchain Recommendations

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

Question has a verified solution.

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

Suggested Solutions

Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to dynamically set the form action using jQuery.
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)

770 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