aman0711
asked on
Format textarea text
Hi folks,
The task I am trying to accomplish is,
I have a textarea on my page and I paste some text from an excel sheet onto this textarea. The format comes up as:
abcd
jhjshds
eyyeye
yueye
ndgdjj
ieieue
iweiene
What I am trying to achieve is, onmouseout function, this input should turn into Comma Seperated Values, like:
abcd, jhjshds, eyyeye, yueye, ndgdjj, ieieue, iweiene
How to go about this?
The task I am trying to accomplish is,
I have a textarea on my page and I paste some text from an excel sheet onto this textarea. The format comes up as:
abcd
jhjshds
eyyeye
yueye
ndgdjj
ieieue
iweiene
What I am trying to achieve is, onmouseout function, this input should turn into Comma Seperated Values, like:
abcd, jhjshds, eyyeye, yueye, ndgdjj, ieieue, iweiene
How to go about this?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi gamarrojgq:
Your solution didnt work either. Its not doing anything on mouseout.
Your solution didnt work either. Its not doing anything on mouseout.
Hi aman0711,
The function use "txtTextArea" as the ID of you textarea control, does your control have this ID?
The function use "txtTextArea" as the ID of you textarea control, does your control have this ID?
ASKER
Hi gamarrojgg,
Yes I do have that. Below is my complete code.
Yes I do have that. Below is my complete code.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script>
function FormatTextArea(){
var sdata;
var newdata = "";
sdata = document.getElementById("txtTextArea").value;
for(i=0; i<sdata.length; i++){
if (sdata[i].charCodeAt(0) == "\n".charCodeAt(0))
{
newdata = newdata + ",";
}
else
{
if(sdata[i].charCodeAt(0) != 13){
newdata = newdata + sdata[i];
}
}
}
document.getElementById("txtTextArea").value = newdata;
}
</script>
</HEAD>
<BODY>
<textarea rows="10" cols="40" id="txtTextArea" onmouseout="javascript:FormatTextArea();" >
</textarea>
</BODY>
</HTML>
errr.PNG
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi hielo,
Long time :)
You are the boss :-) Fixed.
Thanks a ton.
Long time :)
You are the boss :-) Fixed.
Thanks a ton.
ASKER
hi senthurpandian,
Your solutions worked too , just a little problem. Its starting the formatted String with a comma
Your solutions worked too , just a little problem. Its starting the formatted String with a comma
Hi,
I've tried the code and works fine, i'm sending you a file that works in my environment
HTMLPage2.htm
I've tried the code and works fine, i'm sending you a file that works in my environment
HTMLPage2.htm
@hielo
Nice solution. :)
Nice solution. :)
>> Long time :)
Ditto.
>>Thanks a ton.
Anytime
Regards,
Hielo
Ditto.
>>Thanks a ton.
Anytime
Regards,
Hielo
@frzsombor:
Thank you. Occasionally I manage to get one right :)
Thank you. Occasionally I manage to get one right :)
ASKER
Thanks folks. Sorry for closing this late
ASKER
Your solution isnt working right :(
I have attached the snapshot. Multiple commas indicate the number of times I did mouseout.
comma.PNG