Link to home
Start Free TrialLog in
Avatar of lulu50
lulu50Flag for United States of America

asked on

my append to the list

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

Avatar of leakim971
leakim971
Flag of Guadeloupe image

Test page : http://jsfiddle.net/r9LmN/

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

Open in new window

work too : http://jsfiddle.net/r9LmN/2/

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

Open in new window

Avatar of lulu50

ASKER

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.
Not sure... Try this :

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

Open in new window

Avatar of lulu50

ASKER

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>');
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lulu50

ASKER

User generated image
your attributes must have quote at the beggining and at the end
Avatar of lulu50

ASKER

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

Open in new window


User generated image
remove company text, check my two last propositions
Avatar of lulu50

ASKER

Excellent,  

Thank you ++++++