0

I have a code jquery who display a value from mysql data to a modal window form.

editRow: function(row){
var values = row.val();
...
$editor.find('#mail_username').val(values.mail_username);
...
$modal.data('row', row);
$modal.modal('show');
},

Example : The correct value in mysql is "toto&titi"

But in my modal window : "toto&titi"

How to correctly display specials characters in my modal form ?

<input type="text" class="form-control" id="mail_username" name="mail_username" required>

Thanks

Canta
  • 23
  • 6

2 Answers2

0

You can decode your text by

let mail_username = "toto&amp;titi";
let decode = $("<div/>").html(mail_username).text();

let mail_username = "toto&amp;titi";
let decode = $("<div/>").html(mail_username).text();
$('#mail_username').val(decode);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type='text' id='mail_username' />
Hien Nguyen
  • 24,551
  • 7
  • 52
  • 62
  • Thanks a lot Hien !!! My good syntax: $editor.find('#mail_username').val($("
    ").html(values.mail_username).text());
    – Canta Jun 23 '19 at 09:54
0

Thanks a lot Hien !!!

I post below my good syntax:

$editor.find('#mail_username').val($("<div/>").html(values.mail_username).text());
Canta
  • 23
  • 6