简体   繁体   中英

How to Show Currency symbol based on Hexcode Jquery?

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.

Sure - use the technique from this answer :

var currentProp = $("#currency_symbol").attr("value");
var parsedProp = $("<textarea/>").html(currentProp).text();
$("#currency_symbol").attr("value", parsedProp);

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM