1

I want to show Currency Symbol based of hex code,When I change country I get hex code basis on country using Ajax. But I want to display symbol not hex code. I got result like this

<input aria-invalid="false" placeholder="Currency Symbol" name="currency_symbol" readonly="readonly" id="currency_symbol" class="form-control valid" type="text" value="€">

But Browser showing hex code;

Ajax Response is :

$('#country_list').on('change', function() {
    var country  = this.value;
    if(country !=0) {
        var countries_list = JSON.parse('<?php echo json_encode($countries_list) ?>');
        $('#currency_symbol').val(countries_list[country].country_currency_hex);
    }
 });

And I notice one thing When I used developer tool and direct put hexcode its automatically change into symbol.

Jack Bashford
  • 43,180
  • 11
  • 50
  • 79

2 Answers2

1

Sure - use the technique from this answer:

var currentProp = $("#currency_symbol").attr("value");
var parsedProp = $("<textarea/>").html(currentProp).text();
$("#currency_symbol").attr("value", parsedProp);
Jack Bashford
  • 43,180
  • 11
  • 50
  • 79
0

json_encode($array, JSON_UNESCAPED_UNICODE);

i hope that will help with any explaination because this is the common problem

demo: http://sandbox.onlinephpfunctions.com/code/9b7ca5950b2db0b269b61e9d68d9362bdd41c808

plonknimbuzz
  • 2,594
  • 2
  • 19
  • 31