Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- Copy-Paste from MS Excel fails with IE but works with Firefox


kristo5747 - 12:33 am on Jan 26, 2012 (gmt 0)


I built a very simple app using a PHP form with a bit of Javascript.

In my form, I have a text input which I used to run a database search. In case I have multiple values, I have a bit of code that puts a comma in between each.

The weird part is this:

In Firefox, I can go do MS Excel, copy 5 values and paste them in the text input control. I can see all 5 values pasted and commas in between.

In Internet Explorer version 8, I can go do MS Excel, copy 5 values but only ONE value (the first number) gets pasted in the text input control.

This is my html


<fieldset>
<label for="DBRIDs">RIDs</label><input type="text" id="DBRIDs" name="DBRIDs" onchange = "removespaces(this)">
</fieldset>


This is my Javascript in my page header


<script language="javascript" type="text/javascript">
function removespaces(which) {
str = which.value;
str = str.replace (/\s|\n/g,","); // replace space or newline by commas
document.myform.DBRIDs.value = str;
}



Pretty basic stuff.

Tried changing textinput to textarea. No change. Am able to paste without problems from Firefox, Chrome, Safari and even Opera! IE is a no go.

What am I missing? How come IE cannot paste like Firefox?


Thread source:: http://www.webmasterworld.com/javascript/4410903.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com