ขอถาม PHP หน่อยครับ (รบกวนด้วยคับ แง้วๆ)

เริ่มโดย bankkungz, 04 ธันวาคม 2007, 23:17:56

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

payu


โทษทีนะครับ .. พอดีตอบไปไม่ได้ test ก่อน ... มันขาดไป function นึงสำหรับ ie
.. เอาตัวอย่างเต็มๆ ไปเลยละกันครับ


<html>
<head>
<script language="javascript">

function storeCaret(text)
{
// Only bother if it will be useful.
if (typeof(text.createTextRange) != "undefined")
text.caretPos = document.selection.createRange().duplicate();
}

// Surrounds the selected text with text1 and text2.
function surroundText(text1, text2, textarea)
{
// Can a text range be created?
if (typeof(textarea.caretPos) != "undefined" && textarea.createTextRange)
{
var caretPos = textarea.caretPos, temp_length = caretPos.text.length;

caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text1 + caretPos.text + text2 + ' ' : text1 + caretPos.text + text2;

if (temp_length == 0)
{
caretPos.moveStart("character", -text2.length);
caretPos.moveEnd("character", -text2.length);
caretPos.select();
}
else
textarea.focus(caretPos);
}
// Mozilla text range wrap.
else if (typeof(textarea.selectionStart) != "undefined")
{
var begin = textarea.value.substr(0, textarea.selectionStart);
var selection = textarea.value.substr(textarea.selectionStart, textarea.selectionEnd - textarea.selectionStart);
var end = textarea.value.substr(textarea.selectionEnd);
var newCursorPos = textarea.selectionStart;
var scrollPos = textarea.scrollTop;

textarea.value = begin + text1 + selection + text2 + end;

if (textarea.setSelectionRange)
{
if (selection.length == 0)
textarea.setSelectionRange(newCursorPos + text1.length, newCursorPos + text1.length);
else
textarea.setSelectionRange(newCursorPos, newCursorPos + text1.length + selection.length + text2.length);
textarea.focus();
}
textarea.scrollTop = scrollPos;
}
// Just put them on the end, then.
else
{
textarea.value += text1 + text2;
textarea.focus(textarea.value.length - 1);
}
}
</script>

<body>
<a href="javascript:void(0);" onclick="surroundText('[b]', '[/b]', document.forms.f.a); return false;">bold</a><br>
<form name="f">
<textarea name="a" rows="12" cols="60" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onchange="storeCaret(this);"></textarea>
</form>
</body>
</html>


[direct=http://www.facebook.com/iipayu]payu on facebook[/direct]

bankkungz

อ้างถึงonselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onchange="storeCaret(this);"

ผมได้ใส่โค๊ตชุดนี้ลงใน textarae แล้ว

แล้วก้อใส่ฟังชั่น

function storeCaret(text)

แล้ว

แต่ทำไมพอกรอกข้อมูลในฟอร์มแล้ว back กลับมาข้อมูลในฟอร์มหายละครับ
[direct=http://www.bethezank.com]Bethezank[/direct]

payu

อ้างถึงจาก: bankkungz ใน 13 มกราคม 2008, 22:30:00
แต่ทำไมพอกรอกข้อมูลในฟอร์มแล้ว back กลับมาข้อมูลในฟอร์มหายละครับ

เอามาตอบไว้ตรงนี้นะครับเผื่อจะเป็นประโยชน์ ...
ถ้าต้องการให้กด "Back" แล้วข้อมูลในฟอร์มไม่หายไปให้ใส่ประโยคนี้ไว้บนสุดครับ

<? header("Cache-control: private"); ?>
[direct=http://www.facebook.com/iipayu]payu on facebook[/direct]