Skip to content

Instantly share code, notes, and snippets.

@iSWORD
Created October 30, 2012 13:30
Show Gist options
  • Save iSWORD/3980194 to your computer and use it in GitHub Desktop.
Save iSWORD/3980194 to your computer and use it in GitHub Desktop.
HTML+JS Chrome editable select element
<style>
.select-editable { position:relative; background-color:white; border:solid grey 1px; width:120px; height:18px; }
.select-editable select { position:absolute; top:0px; left:0px; font-size:14px; border:none; width:120px; margin:0; }
.select-editable input { position:absolute; top:0px; left:0px; width:100px; padding:1px; font-size:12px; border:none; }
.select-editable select:focus, .select-editable input:focus { outline:none; }
</style>
<div class="select-editable">
<select tabindex="-1" onchange="this.nextElementSibling.value=this.value">
<option value=""></option>
<option value="115x175 mm">115x175 mm</option>
<option value="120x160 mm">120x160 mm</option>
<option value="120x287 mm">120x287 mm</option>
</select>
<input type="text" name="format" value="" onkeydown="if(event.which==40){e=document.createEvent('MouseEvents');e.initMouseEvent('mousedown');this.previousElementSibling.dispatchEvent(e);return false;}"/>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment