Solved

my append to the list

Posted on 2014-03-26
11
242 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
 
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
The viewer will learn how to dynamically set the form action using jQuery.
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…

910 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

21 Experts available now in Live!

Get 1:1 Help Now