简体   繁体   English

使用JavaScript在多行[多行文本框]中显示文本

[英]Displaying Text in multiline [ Multiline textbox] using Javascript

在此处输入图片说明 I tried my best to get this resolved but end up with negative results. 我尽力解决了这个问题,但最终结果是负面的。

I have text box, and the length is 1300 chars. 我有文本框,长度为1300个字符。 But I want that to display in multilines. 但是我希望它以多行显示。 I tried a lot of things and I got horizontal scrollbar but didn't get the vertical scroll bar. 我尝试了很多事情,但得到了水平滚动条,但没有得到垂直滚动条。 The string is displaying in a single line which I don't want. 该字符串显示在我不希望的一行中。 I want that to break at end of the textbox and continue displaying on the next line. 我希望它在文本框的结尾处中断,并继续在下一行显示。

var  tmpArray = document.forms['form1'].elements["fa_col_value"];
var mainCdo = g_CdoMgr.getCdoByName("TempFaObjectCdo");
var flexCdoCol = mainCdo.getCdoColByName("fa");

if(flexCdoCol.get(i).getField("label") == "Additional Notes" )
{
    tmpArray[i-j].style.width="350";
    tmpArray[i-j].style.height="100";
}

In the above code, I tried to change the height and width but displaying is what bothers me. 在上面的代码中,我试图更改高度和宽度,但是显示却让我感到困扰。 I want this to be displayed over multiple lines. 我希望将其显示在多行上。 This is generic for all the elements in that page. 这对于该页面中的所有元素都是通用的。

//tmpArray[i-j].style.overflow="auto";

When using this I'm getting a horizontal scroll bar also [which is not useful for me]. 使用此功能时,我也会得到一个水平滚动条[对我来说没有用]。 but when I tried vertical options that is not working at all. 但是当我尝试垂直选项时根本不起作用。

I tried break-all / break-word , but no use. 我试过了break-all / break-word ,但是没有用。

图片1

The image shows the data. 该图显示了数据。 Red represents the part which I need to change, and green is the string that need to be displayed in multiline. 红色代表我需要更改的部分,绿色代表需要多行显示的字符串。

图片2

Here the string is displaying in single line. 字符串在这里显示为单行。 That needs to be rendered vertically. 需要垂直渲染。

I think this is related to your problem. 我认为这与您的问题有关。

Please see 请参见

Paste multiline text in input type text (not textarea) 将多行文本粘贴到输入类型的文本中(不是textarea)

您正在使用输入字段,但是应该使用textarea http://www.w3schools.com/tags/tag_textarea.asp,因为textarea用于多行文本显示

Alternatively you can use text area with small jQuery Code. 或者,您可以在小型jQuery代码中使用文本区域。

      $("#tArea").on("keydown", function () {
          var $that = $(this);
          if ($that.val().length >= 50) {

              $that.val($that.val().substring(0, 49));


          }


      });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM