Jump to content

michaelk

New Members
  • Content Count

    2
  • Joined

  • Last visited

Everything posted by michaelk

  1. michaelk

    js encoding help utf-8

    Hi, I have the following code: <input name="data" type="text" id="data" value="<?php print utf8_decode($data_attiva)?>" size="30" readonly onChange="aggiorna_data_nascosta()" style="font-size:15px; font-weight:bold"> <input type="button" id="trigger" onClick="" value="scegli data" style="background-image:url(img/icons/calendar-gray.png); background-repeat:no-repeat; background-position: 5px center; padding-left:25px"> <script type="text/javascript"> Calendar.setup({ inputField : "data", // id of the input field ifFormat : "%A %d %B %Y", // format of the input field (even if hidden, this format will be honored) daFormat : "%A %d %B %Y", button : "trigger", // ID of the span where the date is to be shown weekNumbers : "true", range : [2002, (new Date().getFullYear())+2] }); </script> And the following js function: function aggiorna_data_nascosta() { var yearCurrent = now.getYear(); var day=window.calendar.date.getDate(); var month=window.calendar.date.getMonth(); var year=window.calendar.date.getFullYear(); var listYears=document.getElementById('anno'); for (i=0; i<listYears.length; i++) { if (listYears.options[i].text == year) { document.getElementById('anno').selectedIndex=i; } } document.getElementById('giorno').selectedIndex=day-1; document.getElementById('mese').selectedIndex=month; } The problem is the following: When I open the page I see the date in the right encoding... for example "Venerdì 11 Gennaio 2019"... thanks to the PHP function "utf8_decode(data_attiva)" in the first line. Unfortunately when I click the button with id "trigger" and I change the date the new date appears in the wrong encoding... for example it becomes "Venerdì 11 Gennaio 2019". Can you suggest me a way to put the date to the right encoding when I change the date with javascript? My current PHP header of the page is: header('Content-Type: text/html; charset=iso-8859-1');
  2. michaelk

    js encoding help utf-8

    Yep sure but I am handling with an old app written in PHP 5 that has three different charsets (UTF-8, ASCII and ISO 8859-1). It's very complicated using UTF-8 instead of ISO 8859-1 for the pages (I have already tried it...). I was wondering if it's possible to put some utf8-decode directly in the javascript code... and where. I am not very expert about Javascript...
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.