Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy-Paste from MS Excel fails with IE but works with Firefox

Status
Not open for further replies.

kristo5747

Programmer
Mar 16, 2011
41
0
0
US
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

Code:
    <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

Code:
<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??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top