Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Code that adds +"

    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?

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Please try the following


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

  • #3
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts
    but i need it for every single line

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,048
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Do you mean the user enters text into a textarea? Please explain more.

  • #5
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yes yes... dunno why this took me so long to reply really sorry... must have overlooked it... sorry again

  • #6
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    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.

    Code:
    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
    Helping to build a bigger box. - Adam Matthews

  • #7
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,048
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Code:
    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?

  • #8
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #9
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    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
    Helping to build a bigger box. - Adam Matthews

  • #10
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •