Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > [javascript] ช่วยหน่อยครับ เขียนโค้ดแทรก BB Code แล้วมันไม่ยอมทำงาน กดแล้วขึ้นอะไร ทั้งๆที่โหลดจากของที่นี่ลองเอาไปแก้ดู



 

[javascript] ช่วยหน่อยครับ เขียนโค้ดแทรก BB Code แล้วมันไม่ยอมทำงาน กดแล้วขึ้นอะไร ทั้งๆที่โหลดจากของที่นี่ลองเอาไปแก้ดู

 



Topic : 093749



โพสกระทู้ ( 46 )
บทความ ( 0 )



สถานะออฟไลน์




ช่วยหน่อยครับ เขียนโค้ดแทรก BB Code แล้วมันไม่ยอมทำงาน กดแล้วขึ้นอะไร ทั้งๆที่โหลดจากของที่นี่ลองเอาไปแก้ดู
เพราะเว็บผมทำส่วนของ BB Code ไว้แล้วแต่ยังไม่ได้ทำส่วนของปุ่มแทรก



Tag : JavaScript, Ajax, jQuery







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-04-12 14:09:11 By : phoomin2012 View : 1035 Reply : 8
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ลองไล่ดูดี ๆ ครับ หรือไม่เอา Code มาแปะดูครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-04-12 15:21:15 By : mr.win
 


 

No. 2



โพสกระทู้ ( 46 )
บทความ ( 0 )



สถานะออฟไลน์


ตอนนี้แก้ได้แล้วครับ ขอบคุณครับสำหรับคำแนะนำ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-04-12 16:05:51 By : phoomin2012
 

 

No. 3



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-04-12 17:22:57 By : mr.win
 


 

No. 4



โพสกระทู้ ( 46 )
บทความ ( 0 )



สถานะออฟไลน์


ขออนุณาตนะครับ พี่แอดมินช่วยเอาแจกเลยได้ไหมครับ ของ Thaicreate อะครับ
พอดีอยากได้แบบกดแล้ว cursor อยู่ตรงกลาง พอดีโค้ดของผมมันจะเพิ่มตรงส่วนท้ายของตัวหนังสือทั้งหมดอะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-04-12 22:06:59 By : phoomin2012
 


 

No. 5



โพสกระทู้ ( 46 )
บทความ ( 0 )



สถานะออฟไลน์


ขอดันอีกอันนะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-04-13 09:57:02 By : phoomin2012
 


 

No. 6



โพสกระทู้ ( 1,819 )
บทความ ( 20 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Facebook

ทำไมต้องดันให้เขาแจกครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-04-13 14:27:44 By : cookiephp
 


 

No. 7



โพสกระทู้ ( 46 )
บทความ ( 0 )



สถานะออฟไลน์


พอหาในเน็ตแล้วของไทยมันมีแต่แบบแทรกไว้หลังสุดของข้อความทั้งหมดนะครับ
แล้วผมต้องเอาไปทำ Project ของผมให้เสร็จด้วยครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-04-13 14:35:42 By : phoomin2012
 


 

No. 8



โพสกระทู้ ( 1,819 )
บทความ ( 20 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Facebook

ผมเขียนตัวอย่างให้ดูครับ

<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script> // อ้างอิงจาก // http://stackoverflow.com/questions/401593/understanding-what-goes-on-with-textarea-selection-with-javascript function get_selection(the_id) { var e = document.getElementById(the_id); //Mozilla and DOM 3.0 if('selectionStart' in e) { var l = e.selectionEnd - e.selectionStart; return { start: e.selectionStart, end: e.selectionEnd, length: l, text: e.value.substr(e.selectionStart, l) }; } //IE else if(document.selection) { e.focus(); var r = document.selection.createRange(); var tr = e.createTextRange(); var tr2 = tr.duplicate(); tr2.moveToBookmark(r.getBookmark()); tr.setEndPoint('EndToStart',tr2); if (r == null || tr == null) return { start: e.value.length, end: e.value.length, length: 0, text: '' }; var text_part = r.text.replace(/[\r\n]/g,'.'); //for some reason IE doesn't always count the \n and \r in the length var text_whole = e.value.replace(/[\r\n]/g,'.'); var the_start = text_whole.indexOf(text_part,tr.text.length); return { start: the_start, end: the_start + text_part.length, length: text_part.length, text: r.text }; } //Browser not supported else return { start: e.value.length, end: e.value.length, length: 0, text: '' }; } function replace_selection(the_id,replace_str) { var e = document.getElementById(the_id); selection = get_selection(the_id); var start_pos = selection.start; var end_pos = start_pos + replace_str.length; e.value = e.value.substr(0, start_pos) + replace_str + e.value.substr(selection.end, e.value.length); set_selection(the_id,start_pos,end_pos); return {start: start_pos, end: end_pos, length: replace_str.length, text: replace_str}; } function set_selection(the_id,start_pos,end_pos) { var e = document.getElementById(the_id); //Mozilla and DOM 3.0 if('selectionStart' in e) { e.focus(); e.selectionStart = start_pos; e.selectionEnd = end_pos; } //IE else if(document.selection) { e.focus(); var tr = e.createTextRange(); //Fix IE from counting the newline characters as two seperate characters var stop_it = start_pos; for (i=0; i < stop_it; i++) if( e.value[i].search(/[\r\n]/) != -1 ) start_pos = start_pos - .5; stop_it = end_pos; for (i=0; i < stop_it; i++) if( e.value[i].search(/[\r\n]/) != -1 ) end_pos = end_pos - .5; tr.moveEnd('textedit',-1); tr.moveStart('character',start_pos); tr.moveEnd('character',end_pos - start_pos); tr.select(); } return get_selection(the_id); } </script> <title>BBCode Example</title> </head> <body> <script> function bbcode(tag) { var s = get_selection('txt'); if (s.text) { replace_selection('txt', '[' + tag + ']' + s.text + '[/' + tag + ']'); } else { replace_selection('txt', '[' + tag + '][/' + tag + ']'); var p = s.end + tag.length + 2; set_selection('txt', p, p); } } </script> <form action="" method="get"> <input onclick="bbcode('b');" type="button" value="Bold" /> <input onclick="bbcode('i');" type="button" value="Italic" /> <input onclick="bbcode('u');" type="button" value="Underline" /> <input onclick="bbcode('img');" type="button" value="IMG" /> <input onclick="bbcode('url');" type="button" value="URL" /> <br /> <textarea cols="80" rows="20" id="txt"></textarea> </form> </body> </html>


โดยใช้ฟังก์ชั่นอ้างอิงจากลิงก์นี้

http://stackoverflow.com/questions/401593/understanding-what-goes-on-with-textarea-selection-with-javascript
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-04-13 15:15:42 By : cookiephp
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : [javascript] ช่วยหน่อยครับ เขียนโค้ดแทรก BB Code แล้วมันไม่ยอมทำงาน กดแล้วขึ้นอะไร ทั้งๆที่โหลดจากของที่นี่ลองเอาไปแก้ดู
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 03
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่