views:

50

answers:

2

Hello!

Please take a look here: http://www.binarymark.com/Products/FLVDownloader/order.aspx

What I am trying to do is to get rid of the prices inside the option tag. On that page you can see a drop-down box under Order Information, Product. I want to remove the prices from all the options that contain them in that box, so get rid of " - $75.98" for example. I am not used to JQuery, but I realize it would be possible - just not sure how to do it, so your help would be greatly appreciated.

Thanks. George

A: 

Unfortunately based on your country of origin, Plimus is not allowed to continue this process. So I cant help you! :)

but this is the general idea:

if ($('#field > div.field-item:contains("someText")').length > 0) {
$("#somediv").addClass("thisClass");
}
XGreen
+1  A: 

Something like this should do the trick:

$('select[name="contractId"] > option').each(function ()
{
    var $this = $(this);
    $this.text($this.text().split(/\s-/)[0]);
});

That should split the text into an array with the "wanted" part as index 0, and set the text to whatever is contained in that index. You could also use a replace regex if you wanted to.

It would make more sense to do this server-side really, if a user has JS disabled on their machine you could run into problems with displaying incorrect prices.

Andy E
Thanks a lot! That did the trick! But will it work across all major browsers?
George
@George: jQuery handles the browser differences with `text()`, and although `split` does vary by implementation this particular regex should work the same across all implementations.
Andy E