Have you considered using JQuery? What you are trying to achive can easily be done like this
<input type="text" list="cars" id='disableTyping' />
<datalist id="cars">
<option>Volvo</option>
<option>Saab</option>
<option>Mercedes</option>
<option>Audi</option>
</datalist>
<script type="text/javascript">
$('#disableTyping').keypress(function(e) {
return false;
});
</script>
And also if you decide to use this approach make sure to include JQuery in the <head></head>
of your page.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…