how to get rid of the new line blanks in textarea?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • karenkksh
    New Member
    • Jun 2007
    • 15

    how to get rid of the new line blanks in textarea?

    <%Function ListCPN()%>

    <!--<textarea class="project" name="txtCPN"></textarea>-->

    <TEXTAREA class="project" name="txtCPN" cols="35" rows="10"></TEXTAREA>


    <%End Function%>
    Last edited by karenkksh; Jun 28 '07, 09:25 AM. Reason: wrong typing
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    karen,

    this shouldn't give you any blank lines. It didn't when I tried it just now.

    Jared

    Comment

    • karenkksh
      New Member
      • Jun 2007
      • 15

      #3
      Originally posted by jhardman
      karen,

      this shouldn't give you any blank lines. It didn't when I tried it just now.

      Jared
      Hi Jared,

      Thanks. I would like to trim off if there is enter blank in text area so that no empty fields are shown in the table of the following page.

      Users can only enter CPN line by line but cannot press enter key for new line.
      Last edited by karenkksh; Jun 29 '07, 01:41 AM. Reason: noi clear enough

      Comment

      • jhardman
        Recognized Expert Specialist
        • Jan 2007
        • 3405

        #4
        Oh, I think I understand. So a user theoretically might enter a blank line which you don't want. Well, if you want to handle this with asp you could say:
        [code=asp]dim lines, x, outputText
        lines = split(request(" myTextBox"), vbNewLine)
        for each x in lines
        if trim(lines(x)) <> "" then
        outputText = outputText & lines(x) & vbNewLine
        end if
        next[/code]and you are left with outputText which includes all of the original request.form("m yTextBox") minus any blank lines.

        Does that work for you?

        Jared

        Comment

        • karenkksh
          New Member
          • Jun 2007
          • 15

          #5
          Originally posted by jhardman
          Oh, I think I understand. So a user theoretically might enter a blank line which you don't want. Well, if you want to handle this with asp you could say:
          [code=asp]dim lines, x, outputText
          lines = split(request(" myTextBox"), vbNewLine)
          for each x in lines
          if trim(lines(x)) <> "" then
          outputText = outputText & lines(x) & vbNewLine
          end if
          next[/code]and you are left with outputText which includes all of the original request.form("m yTextBox") minus any blank lines.

          Does that work for you?

          Jared


          Thanks. no syntax error but it doesn't work. The empty fields still showed in the tables of following page.

          Why?
          [code=asp]
          <%Function ListCPN()%>


          <TEXTAREA class="project" name="txtCPN" cols="35" rows="10"><%Cal l trimLines%></TEXTAREA>


          <%End Function%>


          <%
          Function trimLines

          dim lines, x, outputText
          lines = split(request(" txtCPN"), vbNewLine)
          for each x in lines
          if trim(lines(x)) <> "" then
          outputText = outputText & lines(x) & vbNewLine
          end if
          next

          End Function

          %>[/code]

          Comment

          • jhardman
            Recognized Expert Specialist
            • Jan 2007
            • 3405

            #6
            This is the code for the page where the user enters the info? It won't work there. Remember that ASP code only works WHILE the server is sending the page to the user. I had intended this code to be the code on the following page. and I think I got part of the code wrong anyway. I just tried this to make sure. the entire form was saved as "texttest.a sp". The form submits to the same page, and everytime all of the blank lines are taken out and the text (minus any blank lines) is put in the textarea.
            [code=asp]<%
            dim lines, x, outputText
            lines = split(request(" myText"), vbNewLine)
            for each x in lines
            if trim(x) <> "" then
            outputText = outputText & x & vbNewLine
            end if
            next %>
            <form action="texttes t.asp" method="post">
            <textarea name="myText">< %=outputText%></textarea>
            <input type="submit" name="submit" value="submit">
            </form>[/code]

            Comment

            • karenkksh
              New Member
              • Jun 2007
              • 15

              #7
              The enter blanks cannot be cut off and the blanks still showed in the table of following page.
              I need to use Next pagelink instead of submit input.
              The bold link is the link to the following page.


              Dim rsEmail, qryEmail
              Dim res
              Dim strInput, Count

              Dim lines, x, outputText
              lines = split(request(" txtCPN"), vbNewLine)
              for each x in lines
              if trim(x) <> "" then
              outputText = outputText & x & vbNewLine
              end if
              next

              <form name="frmInput" action="ApprovePartsDis play.asp" method="post">

              <tr class="filter">
              <td width="120"></td>
              <td></td>
              <td><a onclick="javasc ript:document.f rmInput.submit( )"><font class="pageLink ">&gt&gt Next</font></a></td>
              </tr>

              <%Function ListCPN()%>


              <TEXTAREA class="project" name="txtCPN" cols="35" rows="10"><%=ou tputText%></TEXTAREA>


              <%End Function%>

              Comment

              • jhardman
                Recognized Expert Specialist
                • Jan 2007
                • 3405

                #8
                Karen,

                I am no longer following what you are saying. What is generating the content of the textarea? If you are generating the textarea, then just don't put in blank lines. If the user is filling it out, then remove the blank lines before you save it. I don't understand which part is giving you trouble.

                Jared

                Comment

                Working...