我試圖將換行符打印到textarea中。PHP將換行打印到textarea中
我有這個字符串:
$coords = $row->lat.','.$row->lon."\r\n"
當我使用下面的JavaScript命令:
alert(coords);
我得到:
-35.308401,149.124298
-35.307841,149.124298
然而,當我在觀看一個textarea,我得到:
-35.308401,149.124298 -35.307841,149.124298
如何在textarea中顯示換行符?
更多信息:
警報窗口顯示:
textarea的:
代碼:
<textarea name="addrs" rows=5 cols=80>-35.308401,149.124298 -35.307841,149.124298</textarea>
更多信息: 這是如何創建表格和文本寫入文本區域
function openMapWindow (data) {
alert(data);
var mapForm = document.createElement("form");
mapForm.target = "Map";
mapForm.method = "POST"; // or "post" if appropriate
mapForm.action = "http://www.xxx.com/map.php";
var mapInput = document.createElement("input");
mapInput.type = "text";
mapInput.name = "addrs";
mapInput.value = data;
mapForm.appendChild(mapInput);
document.body.appendChild(mapForm);
map = window.open("", "Map", "status=0,title=0,height=600,width=800,scrollbars=1");
if (map) {
mapForm.submit();
} else {
alert('You must allow popups for this map to work.');
}
}
function mapSuppliers(customer_id) {
$.get("get.map.points.php", { c_id: customer_id },
function(data){
if (data!='') {
openMapWindow(data);
} else {
alert("Missing map coordinates - cannot display map (data: " + data + ")");
}
});
}
:
隨着PHP:
隨着JS您的網絡瀏覽器的頁面,是否有線路回報,如你所期望的? – erisco 2011-04-17 03:43:31
你說PHP,但你通過JS測試。你怎麼真的把數據傳遞給textarea?它是通過PHP內聯的嗎? – Khez 2011-04-17 03:49:04
@Khez - 查看編輯 – 2011-04-17 03:56:57