Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7178791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:59:28+00:00 2026-05-28T16:59:28+00:00

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

  • 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. What am I missing? How come IE cannot paste like Firefox??

EDIT

I had a typo so using textarea is working now. I can copy a column and paste it from IE

Of course (sarcasm), it is introducing a new problem: It duplicates my commas and I am unclear it’s because of textarea or my Javascript.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T16:59:29+00:00Added an answer on May 28, 2026 at 4:59 pm

    An input with a type of text does not support new line characters. As such, IE strips them automatically, and you never have a chance to even parse them. Your best bet may be to use a textarea instead.

    Alternatively, you could do something like the below, but it’s really just a workaround (note the onpaste event):

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

    and for the javascript, something like:

    function removespaces (which) {
        var str = which.value;
        str = str.replace(/\s|\n/g, ","); // replace space or newline by commas
        which.value = str;
    }
    
    function handlePaste (which) {  
        var str = window.clipboardData.getData("Text");    
        str = str.replace(/\s|\n/g, ","); // replace space or newline by commas
        which.value = str;
        return false; // kill the paste event so you don't get duplicate data.
    }
    

    jsfiddle example here: http://jsfiddle.net/fordlover49/mJ7L3/

    On a related note (to try and help you avoid further problems), your passing in the element to the removespaces function, but hardcoding which element you’re setting, instead of using the element passed in.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have built a very simple blog application using Ruby on Rails. New to
Here's my situation; I've built a very simple web app that looks up a
I'm trying to build a very simple OpenGL-app under Ubuntu 10.04 (I have a
I have written a C++ application, which I built using g++. For the purposes
I'm working on a very simple web app, written in Go language. I have
I am using Web2Py to create a simple app which sends Push notifications through
I try to make an app which manages client's contacts. The form is very
I'm using jQTouch to build a simple mobile app with an html/js/jquery form that
I'm trying to build a very, very simple micro-webapp which I suspect will be
Using python 2.4 and the built-in ZipFile library, I cannot read very large zip

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.