简体   繁体   English

HTML textarea显示br

[英]HTML textarea show br

i have a textarea in HTML. 我在HTML中有一个textarea。 In the textarea the blank line is is looks br. 在textarea中,空白行是br。

I try to have the value of the some text. 我尝试获得一些文本的价值。 And posting with get. 并用get发布。 After i received with php. 在我收到PHP后。 And i changed the value of the some text to variabled i get with get. 我将一些文本的值更改为使用get获得的变量。

Like this : 像这样 :

a<br />b c

Code (post with javascript): 代码(使用javascript发布):

<script type="text/javascript">

        function nl2br (str, is_xhtml) {
    var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br>';
    return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2');
}

        function menusec(secilen){

            var deger = secilen.options[secilen.selectedIndex].value;
            var urunadi = document.getElementById("okulueua").value;
            var urunfiyati = document.getElementById("okulueuf").value;
            var kargofiyati = document.getElementById("okuluekf").value;
            var aciklama = nl2br(document.getElementById("okulueat").value);

            alert(aciklama);

            window.location.href = "okulue.php?menu=" + deger + "&urunadi=" + urunadi + "&urunfiyati=" + urunfiyati + "&kargofiyati=" + kargofiyati + "&aciklama=" + aciklama;

        }

    </script>

Code (get with php) : 代码(使用php获取):

<?php

    if (isset($_GET['menu'])) {

        $secilendeger = filter_input(INPUT_GET, "menu");

        $urunadiget = filter_input(INPUT_GET, "urunadi");

        $urunfiyatiget = filter_input(INPUT_GET, "urunfiyati");

        $kargofiyatiget = filter_input(INPUT_GET, "kargofiyati");

        $aciklamaget = filter_input(INPUT_GET, "aciklama");

        echo($aciklamaget);

        ?>

        <script type="text/javascript">

            function br2nl($content){

                $content = str_ireplace("<br /> ", "\n", $content);
                return $content;

            }

            function br2nl1($input){
    return preg_replace('/<br(\s+)?\/?>/i', "\n", $input);
}

            document.getElementById("menusecme1").style.width = "315px";

            document.getElementById("okulueua").value = "<?php echo($urunadiget); ?>";

            document.getElementById("okulueuf").value = "<?php echo($urunfiyatiget); ?>";

            document.getElementById("okuluekf").value = "<?php echo($kargofiyatiget); ?>";

            document.getElementById("okulueat").value = "<?php echo($aciklamaget); ?>";

            $('select[name^="ms1"] option[value="<?php echo($secilendeger); ?>"]').attr("selected","selected");

        </script>

Code (HTML) : 代码(HTML):

<input type="text" class="okulueuat" name="okulueua" id="okulueua">
<input type="text" class="okulueua2t" name="okulueua2" value="1000" readonly="yes">
<input type="text" class="okulueuft" name="okulueuf" id="okulueuf">
<input type="text" class="okuluekft" name="okuluekf" value="5" id="okuluekf">
<input type="submit" class="tamamb2" value="Tamam" name="submit">
<input type="button" class="iptalb2" value="İptal" onclick="location='okulul.php'">
<input type="file" name="okuluef[]" class="resimeklec" multiple="multiple">

<textarea id="okulueat" name="okuluea"></textarea>

How can i solve this problem? 我怎么解决这个问题?

I need your help. 我需要你的帮助。

Note : I don't have a good English. 注意:我的英语不好。 Pardon me. 对不起。 I hope you understand. 我希望你明白。

尝试这个:

 <textarea>a&#13;&#10;b c</textarea>

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

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