<select name="products">
<option value=""> - Choose - </option>
<option value="01">table</option>
<option value="02">chair</option>
<option value="03">book</option>
<option value="04">car</option>
</select>
I want to be able to copy text automatically on selecting a particular option…
Eg. If I select book, book should automatically be copied, so I can paste(Ctrl+v) it somewhere else..Thanks
Copying to the clipboard is a tricky task to do in Javascript in terms of browser compatibility. The best way to do it is using a small flash. It will work on every browser. You can check it in this article.
Still, just for giving you a hint, here’s how to do it for Internet Explorer (just because it is the easiest one to do):
Now your select calls the javascript function onchange event. This event is triggered whenever a new value is selected: