ใช้ iframe แทน textarea + PHP หรือ ASP

เริ่มโดย เก๋าลัดคุง, 09 พฤศจิกายน 2008, 11:24:22

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

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

เก๋าลัดคุง

ใช้ iframe แทน textarea + PHP หรือ ASP

ผมใช้ iframe แทน textarea + PHP หรือ ASP
อ้างถึง<iframe id="edit" src="edit.html" width="100%" height="200px"></iframe>
มันติดตรงที่ ค่า Form ของ  iframe จะใช้ PHP
$_POST['edit'] รับค่ายังไงครับผม

ใช้โค้ด Rich และ wysiwg แบบ Mozilla Rich
http://www.mozilla.org/editor/midasdemo/

ขอบพระคุณครับผม
[direct=https://www.mescript.com/]Pc Game Download [/direct]
[direct=https://www.mescript.com/]Pc Game Download [/direct]
[direct=https://www.mescript.com/]Pc Game Download [/direct]
[direct=https://www.mescript.com/]Computer Programming and Knowledge make By MeScript.com.com [/direct]
[direct=https://www.mescript.com/]รับพัฒนาเว็บไซต์ + รับจดโดเมน + Hosting ราคาถูก [/direct]

Tee++;

ผมว่า มันน่าจะแบบนรี้มากกว่านะครับ

<iframe id="chatEditor" style="width:300px;height:300px;"></iframe>
<script>
chatEditor.document.write("<?php
$explodeResult explode("\r\n"$content);
$total sizeof ($explodeResult);
print("<body bgcolor='#33CC66'><font face='ms sans serif' size='2'>");
for ($count 0$count $total$count ++) {
print($explodeResult[$count]);
}
print("</font></body>");
?>
")

function set_x(){
var x = chatEditor.document.body.innerHTML;
document.theform.hidden_x.value = x;
}

function setMode(bMode){
var sTmp;
isHTMLMode = bMode;
if (isHTMLMode){
sTmp=chatEditor.document.body.innerHTML;chatEditor.document.body.innerText=sTmp;
}
else {
sTmp=chatEditor.document.body.innerText;chatEditor.document.body.innerHTML=sTmp;
}
chatEditor.focus();
}

frames.chatEditor.document.designMode = "on"
</script>


<!-- ค่าส่งไป -->
<input type="hidden" name="hidden_x" value="">
[direct=http://laravel.in.th]Laravel in Thai[/direct]
[direct=http://jquerytips.com]jQueryTips by Tee++;[/direct]
[direct=https://www.facebook.com/jQueryTips]jQueryTips Page[/direct]
[direct=https://www.facebook.com/Laravel.in.th]Laravel in Thai Page[/direct]
[direct=https://twitter.com/Teepluss]Teepluss's Twitter[/direct]


เก๋าลัดคุง

<Script  language="javascript">
function check_form(){
var x  ;
x= edit.document.body.innerHTML;
document.form.comment.value = x;
}
</script>


ขอบพระคุณมากๆ ครับ ชิ้ช่องทาง ผมพิ่มค่า ตาม code เวลา post  :'(
[direct=https://www.mescript.com/]Pc Game Download [/direct]
[direct=https://www.mescript.com/]Pc Game Download [/direct]
[direct=https://www.mescript.com/]Pc Game Download [/direct]
[direct=https://www.mescript.com/]Computer Programming and Knowledge make By MeScript.com.com [/direct]
[direct=https://www.mescript.com/]รับพัฒนาเว็บไซต์ + รับจดโดเมน + Hosting ราคาถูก [/direct]

เก๋าลัดคุง

ผมติดอีกนิดครับ จะทำแบบ นี้ครับ >>>>  ???
click ที่รูปแล้ว ไปติดที่ form

function insertemoticon(emoticon) {
var x  ;
var emoticon ;
var smi = "<img src='/emoticons/small/"+emoticon+"'>";

x= edit.document.body.innerHTML;
document.form.comment.value = x;
x=x+smi;
edit.document.body.innerHTML=x;
}


ผมใช้ code แบบนี้มัน ต่อที่ ข้อความสุดท้าย อยากจะใช้ไว้จุด focus();

เช่น

อ้างถึง
ข้อความ
mouse << อยู่นี้กดรูป  ??? ได้เลย
ข้อความ

ไม่ทราบคำสั่ง JavaScript ครับ ชี้แนะทีครับ ขอบคุณครับ งง คำถามผมไหม
[direct=https://www.mescript.com/]Pc Game Download [/direct]
[direct=https://www.mescript.com/]Pc Game Download [/direct]
[direct=https://www.mescript.com/]Pc Game Download [/direct]
[direct=https://www.mescript.com/]Computer Programming and Knowledge make By MeScript.com.com [/direct]
[direct=https://www.mescript.com/]รับพัฒนาเว็บไซต์ + รับจดโดเมน + Hosting ราคาถูก [/direct]

Tee++;

#4
อ้างถึงไม่ทราบว่าคุณ "Tee++;" พอจะแก้ปัญหานี้ของผมได้ไหมครับ

ถ้าคุณ "Tee++;" ไม่ทราบวิธีแก้ไขก็ไม่ได้ก็ไม่เป็นไรครับ

ขอบพระคุณครับผม
^
^
^
พูดแบบนี้มันเหมือน หลอกล่อกันนี่  >:(
(ล้อเล่นๆ)


ตัว iframe มันมี id ใช่มั้ยครับ แล้ววิธีที่จะเข้าถึง data ของ iframe ตัวนี้คือเรียก

id.document.body.innerHTML  --> นี่คือข้อมูลที่เราพิมพ์

ดังนั้นการที่เราจะได้ค่ามันเราจะต้องสร้างปุ่ม submit แล้วก็ input hidden สักตัว

พอเรากดที่ ปุ่ม สมมุติเป็น แบบนี้

<input type="button" value="Save" onclick="savedata();" />

คือพอเรากดปุ่มเราจะ ไปเรียก function savedata

แล้ว เรามาสร้าง input hidden กัน แบบนี้

<input type="hidden" name="editdata" id="mrx" />

สุดท้ายแล้วเรามาเขียน function ตามที่เราเรียกคือ

function savedata()
{
  // ตัว id คือ id ของ iframe นะ
  var alldata = id.document.body.innerHTML;
  // จับยัดลง hidden
  document.getElementById('mrx').value = alldata;


  // สุดท้ายแล้วก็สั่งให้ form ที่ครอบมันอยู่ submit เสีย
  //eg
  document.getElementById('frm').submit();
}

-----------------------------------------------
อันนี้ข้อหลัง

function setImage(){
  var temp=window.prompt("กรอก url รูปภาพที่ต้องการแทรก","http://");
  if(temp) setsmile("<img src="+temp+"></img>");
}

function setsmile(what){
  frameID.document.body.innerHTML = frameID.document.body.innerHTML+what;
  frames.frameID.focus()
}

[direct=http://laravel.in.th]Laravel in Thai[/direct]
[direct=http://jquerytips.com]jQueryTips by Tee++;[/direct]
[direct=https://www.facebook.com/jQueryTips]jQueryTips Page[/direct]
[direct=https://www.facebook.com/Laravel.in.th]Laravel in Thai Page[/direct]
[direct=https://twitter.com/Teepluss]Teepluss's Twitter[/direct]


tinnoi

โค้ดดีมากเลย มาแอบ copy เก็บไว้ ขอบคุณมากครับ
[direct=https://trainee.naruthee.com]หาที่ฝึกงาน[/direct] ,
[direct=http://www.piyamitrgroup.com]รับรื้อถอน[/direct] ,
[direct=https://fastvisa2024.weebly.com/]รับทำวีซ่า[/direct] ,
[direct=https://business.10thai.com]10thai[/direct]