Reputation: 11
I'm trying to create an autofill function. I'm using a select list, and based on option selected, some textboxes gets values put into them. The only problem is that I can't get extended ASCII-characters into a textbox with the function I'm using.
JS:
function fillContact() {
var contact = document.getElementById('contact'),
namebox = document.getElementById('namebox');
if (contact.value === 'Bjorn') {
namebox.value = 'Bj' + String.fromCharCode(148) + 'rn';
}
else if (contact.value === 'Tommy') {
namebox.value = 'Tommy';
}
}
HTML:
<select id='contact' onchange='fillContact();'>
<option selected>-Choose contact-</option>
<option value='Bjorn'>Bjorn</option>
<option value='Tommy'>Tommy</option>
</select>
Name: <input type='textbox' id='namebox'>
String.fromCharCode() just doesn't encompass ASCII-character 148 (ö), that I want to put into a textbox. Any other String-function that can make it work? Something like String.getExtendedCharCode(148), or equivalent?
Note that other characters up to 128 works, and that contact 'Tommy' works.
Upvotes: 1
Views: 1571