ยินดีต้อนรับคุณ, บุคคลทั่วไป กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน

เข้าสู่ระบบด้วยชื่อผู้ใช้ รหัสผ่าน และระยะเวลาในเซสชั่น

ThaiSEOBoard.comพัฒนาเว็บไซต์Programmingใครเขียนได้บ้าง จะ Javascript PHP
หน้า: [1]   ลงล่าง
พิมพ์
ผู้เขียน หัวข้อ: ใครเขียนได้บ้าง จะ Javascript PHP  (อ่าน 672 ครั้ง)
0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้
click2dd
คนรักเสียว
*

พลังน้ำใจ: 2
ออฟไลน์ ออฟไลน์

กระทู้: 104



ดูรายละเอียด เว็บไซต์
« เมื่อ: 12 ตุลาคม 2011, 04:36:43 »

พอดีอยากจะเขียนให้มันตัดบทความออกเป็น 3 ส่วนเท่ากัน มีท่านได้เขียนได้รบกวนด้วยครับ โดยนำ บทความที่ ตัดได้ไปลงใน textarea1 ,textarea2, textarea3
รบกวนผู้รู้ด้วยครับ..

พอดีลองเขียนแล้วมันไม่ต่อคำให้มันเลือกมาแต่ตัวสุดท้ายของคำ
โค๊ด:

<html>
<head>
<script type="text/javascript">
function displayResult()
{
var x=document.getElementById("myTextarea").value;
//alert(x);
document.formf.textme1.value=x;
}

function getResult()
 {
  var sText=document.getElementById("myTextarea").value;
   
          aText = sText.split(" ");
      nArray = aText.length;
      nKeyword = nArray /3;
        //  alert(aText);
   
              for (i=0;nArray-1;i  )
                   {
            if (i < nKeyword)
          {
                   document.formf.postText1.value=aText[i]  " ";
      }
                    else if ( i >= nKeyword && i < nArray - nKeyword)
      {
                       document.formf.postText2.value=aText[i]  " ";
   }
    else
  {
       document.formf.postText3.value=aText[i]  " ";
  }
   }

 }
</script>
</head>
<body>

<textarea id="myTextarea" name="txt1" rows="5" cols="150">
At W3Schools you will find all the Web-building tutorials you need, from basic HTML to advanced XML, SQL, ASP, and PHP.
Try to avoid using document.write() in real life JavaScript code. The entire HTML page will be overwritten if document.write() is used inside a function, or after the page is loaded. However, document.write() is an easy way to demonstrate JavaScript output in a tutorial.
</textarea>

<form id="formf" name="formf" method="post" action="">
<textarea id="postText1" name="txtpost" rows="3" cols="50"></textarea>
<textarea id="postText2" name="txtpost" rows="3" cols="50"></textarea>
<textarea id="postText3" name="txtpost" rows="3" cols="50"></textarea><br />
<button type="button" onclick="getResult()">Show name of text split</button>
</form>
</body>
</html>

บันทึกการเข้า

HDTV Go
*~เก้าคุง~*
สายตรวจเสียวบอร์ด
Moderator
เจ้าพ่อบอร์ดเสียว
*****

พลังน้ำใจ: 136
ออฟไลน์ ออฟไลน์

กระทู้: 4,097



ดูรายละเอียด
« ตอบ #1 เมื่อ: 12 ตุลาคม 2011, 05:20:04 »

ไม่รู้ใช่แบบนี้หรือป่าว
http://tinkerbin.com/R4QPRCjv
กดปุ่มเขียวๆ คำว่า Run ตรงซ้ายล่างก่อนนะ
« แก้ไขครั้งสุดท้าย: 12 ตุลาคม 2011, 05:21:00 โดย *~เก้าคุง~* » บันทึกการเข้า
teerstudio
คนรักเสียว
*

พลังน้ำใจ: 4
ออฟไลน์ ออฟไลน์

กระทู้: 122



ดูรายละเอียด เว็บไซต์
« ตอบ #2 เมื่อ: 12 ตุลาคม 2011, 07:32:36 »

สุดยอดมากครับ
บันทึกการเข้า

ProDevTH https://www.facebook.com/prodevth
-------------------------------------------------------------------------
click2dd
คนรักเสียว
*

พลังน้ำใจ: 2
ออฟไลน์ ออฟไลน์

กระทู้: 104



ดูรายละเอียด เว็บไซต์
« ตอบ #3 เมื่อ: 12 ตุลาคม 2011, 19:27:16 »

ขอบคุณมากครับ...แบบนี้แหละครับ และมันตัดเป็นตัวอักษร อยากให้ตัดเป็นคำนะครับ...
(ได้คืบจะเอาศอก)

« แก้ไขครั้งสุดท้าย: 12 ตุลาคม 2011, 19:56:51 โดย click2dd » บันทึกการเข้า

HDTV Go
หน้า: [1]   ขึ้นบน
พิมพ์