I have an HTML table element, with rows containing not only plain-text characters, but also radio buttons, lists, etc.
What I would like to have, is when the user copy-pastes the content of the table into MS Excel (as plain text), the radio buttons should be replaced with their values (e.g.: “checked”, and “unchecked”), lists elements should be replaced by their selected value, etc.
Is there a way to implement this in the browser?
(Preferably without using flash or java applet components)
Thanks,
krisy
You could use javascript (this will be easier with a framework like jquery) to modify the code that has been copied. The general procedure would be to set the radio buttons to be invisible and then add in text in their place based on their current value.
There are plenty of questions to help with the implementation details: https://stackoverflow.com/search?q=%5Bjavascript%5D+copied+text&submit=search
Update: Turns out you don’t even need to remove the radio buttons, at least for my version of excel. Here is a working example (way over-commented to explain what’s going on):