Egen Can Egen Can - 26 days ago 7
HTML Question

HTML textarea show br

i have a textarea in HTML. In the textarea the blank line is is looks br.

I try to have the value of the some text. And posting with get. After i received with php. And i changed the value of the some text to variabled i get with get.

Like this :

a<br />b c


Code (post with 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

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) :

<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.

Answer Source

Try this:

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