...

View Full Version : Code that adds +"



JAVAEOC
02-01-2004, 06:41 PM
I need a code that would add a +" in fornt of everylinea and a " on the end of everyline.

It should work like this:

User enters text into a textbox and then i output the test with added +" and ".

any ideas?

Mr J
02-01-2004, 08:02 PM
Please try the following


value="+\" " + document.formName.elementName.value + " \" "

JAVAEOC
02-01-2004, 10:06 PM
but i need it for every single line :(

glenngv
02-02-2004, 04:57 AM
Do you mean the user enters text into a textarea? Please explain more.

JAVAEOC
02-08-2004, 12:05 AM
yes yes... dunno why this took me so long to reply really sorry... must have overlooked it... sorry again

Basscyst
02-09-2004, 02:29 AM
Hello,

Not sure if this will work but you can give it a try. Never tried it with a textarea but it works with a text file.



function breakText()
{
var fixstr="";
var str=document.form.element.value;
var getLines=str.split('\n');
for(i=0;i<getLines.length;i++)
{
fixstr+="+\" " + getLines[i] + " \" ";
}
}


Basscyst

glenngv
02-09-2004, 02:39 AM
function replaceNewline(objText){
var newline = (document.all) ? '\r\n':'\n';
var re = new RegExp(newline,"gi");
objText.value = '+"' + objText.value.replace(re,'"\n+"') + '"';
}
...
<textarea name="msg"></textarea>
<input type="button" value="Insert" onclick="replaceNewline(this.form.msg)">


Newline in IE consists of carriage return (\r) and linefeed (\n) while linefeed only in Moz/NS.

BTW, can you tell us your purpose of inserting such characters?

JAVAEOC
02-10-2004, 01:29 AM
wow very nice ppl.... thanks


Not sure if this will work but you can give it a try. Never tried it with a textarea but it works with a text file.

ha

text file text file text file... its perfect (i only said text area cause i thought its the only way)

HOW would you do it with a text file (would be perfect)

lol
thanks

cool

Basscyst
02-10-2004, 01:47 AM
Do what exactly,

I don't see any code. I have no Idea what you are trying to acomplish. That will take any string and split it by line and then add the characters requested regardless of where the string came from. Use glengv's script for more browser versatility.

Basscyst

JAVAEOC
02-10-2004, 03:32 AM
Heres what i was trying to accomplish.......'

I had a menu (UDM) which i did not want to place on each new page a link goes.... I could use frames, so I though i let a <div> container = to a variable which contains all the HTML and stuff... it would work only in order to have a enter in the variable i would have to add a +",,," to it

and since it was to much to ask the user to add this menually in evrey line i needed a script that does it automatically....

thanks glenndv



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum