I'm want create a form for creating invoices. When I open the page there is one row for a one item. Next to the this row I've a "add new row" link which add one more row. When "add new row" link was clicked the page reloade and the filled data was lost, so I save every input element to cookies with onChange.
I know just few very simple things from javascript.
My problem is a non-ascii character...
The cookie is saved OK, but loaded back without some character like "?,š,?,? ....". The page is in UTF-8.
Code: Select all
<?php
$oneHour = (mktime(date('h')+1));
$oneHour = date('r',$oneHour); // The life time of the cookie
function restoreValue($thisID, $defValue) {
if (isset ($_COOKIE[$thisID])) {
echo $_COOKIE[$thisID];
} else {
echo $defValue;
}
}
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript">
function setcookie(Cname, Cvalue) {
var expire = "<?php echo $oneHour; ?>";
document.cookie = Cname+"="+Cvalue+"; expires="+expire+"; path=/";
}
</script>
</head>
<form>
<input name="Description" id="Description" type="text" value="<?php restoreValue('Description','The description field');?>" onchange="setcookie(this.id, this.value);"/>
</form>G.