I have a search form that displays the merchant data (each sellerโs name, phone number, email address) in a table.
I am looking for a copy of the button next to each of these fields so that users can click on it and copy it to the clipboard (the text will be highlighted when copying). My users will only view IE9.
The problem is that there can be more than one set of results, so the script cannot call a specific numbered function, as I did with the text area below:
function highlightmetasearch01() { document.copydata01.text2copy01.select(); document.copydata01.text2copy01.focus(); } function copymetasearch01() { highlightmetasearch01(); textRange = document.copydata01.text2copy01.createTextRange(); textRange.execCommand("RemoveFormat"); textRange.execCommand("Copy"); } function highlightmetasearch02() { document.copydata02.text2copy02.select(); document.copydata02.text2copy02.focus(); } function copymetasearch02() { highlightmetasearch02(); textRange = document.copydata02.text2copy02.createTextRange(); textRange.execCommand("RemoveFormat"); textRange.execCommand("Copy"); }
HTML:
<textarea name="text2copy01">The first textarea.</textarea> <br /> <button onclick="copymetasearch01();return false;">COPY</button> <textarea name="text2copy02">The second textarea.</textarea> <br /> <button onclick="copymetasearch02();return false;">COPY</button>
I was wondering if this is possible? ...
<td><span>Name from DB here</span> <button onclick="<!--copy and highlight text within most recent span tag-->">COPY</button></td> <td><span>Phone from DB here</span> <button onclick="<!--copy and highlight text within most recent span tag-->">COPY</button></td> <td>Other text here that shouldn't be highlighted or copied <span>Email address from DB here</span> <button onclick="<!--copy and highlight text within most recent span tag-->">COPY</button></td>
Or is there a more efficient way to approach this?
source share