0

Here is my code

var productdetails = {
    productcommission: '%%Commission%%',
    producttotal: '%%GLOBAL_Price%%',
};

It just passes the values to third parties and this is how the values are displayed in the view source.

var productdetails = {
    productcommission: '50',
    producttotal: '$200',
};

I want to know how can i remove dollar sign above So that it shows as below in the view source.

var productdetails = {
    productcommission: '50',
    producttotal: '200',
};
VisioN
  • 143,310
  • 32
  • 282
  • 281
sivi
  • 127
  • 1
  • 1
  • 9
  • 1
    possible duplicate of [Remove characters from a string](http://stackoverflow.com/questions/4846978/remove-characters-from-a-string) – Felix Kling Mar 05 '14 at 18:10
  • It isn't a duplicate. – sivi Mar 05 '14 at 18:24
  • @user1640171 I'd say that the questions are close enough to be duplicates. And if you for some reason can't use that question, here is another one that pretty much also gives you the answer: http://stackoverflow.com/questions/4209130/removing-dollar-signs-from-prices – aaaaaaaaaaaa Mar 05 '14 at 18:31
  • How to make it display in the source code instead of alert? – sivi Mar 05 '14 at 18:36
  • `'$200'` is a string and you want to remove a character (`$`) from that string. How is this not a duplicate? *"How to make it display in the source code instead of alert?"* You have to modify the value **before** it is inserted for `%%GLOBAL_Price%%` (which we don't know anything about). – Felix Kling Mar 05 '14 at 18:36
  • @Felix Kling Just Confused... – sivi Mar 05 '14 at 18:38
  • Yes, that's sums up everything and i have taken it as the straight answer. That there is no solution for my question. – sivi Mar 05 '14 at 18:40

2 Answers2

0

Do I understand that you want the source view to be without leading '$' even if that's the value you get back? I assume that your %% references are filled in by some pre-processing, just as JSP or ASP--if so, that's where you'd want to do the $ removal. Changing the value of the variable in Javascript will give you what you want to see (or use) in the script, but it won't affect the source view. The only way to change the source view (so far as I know) is to change the source before it hits the browser.

And why does it matter what the source view looks like? Or am I simply misreading your question?

user1329482
  • 569
  • 3
  • 8
0

You can remove the dollar sign like this:

var productdetails = {
    productcommission: '50',
    producttotal: '$200'
};

productdetails.producttotal = productdetails.producttotal.replace(/\$/g,'');
R. Oosterholt
  • 7,720
  • 2
  • 53
  • 77