Solved

my append to the list

Posted on 2014-03-26
11
240 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Not sure... Try this :

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

Open in new window

0
 

Author Comment

by:lulu50
Comment Utility
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
Comment Utility
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
Comment Utility
cc
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
your attributes must have quote at the beggining and at the end
0
 

Author Comment

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

Open in new window


c
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
remove company text, check my two last propositions
0
 

Author Closing Comment

by:lulu50
Comment Utility
Excellent,  

Thank you ++++++
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This article discusses how to create an extensible mechanism for linked drop downs.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

762 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

6 Experts available now in Live!

Get 1:1 Help Now