จะส่งค่าจากำ text box ที่เป็น array ไปให้ Ajax อย่างไรหรอครับ

จะส่งค่าจาำก text box ที่เป็น array ไปให้ Ajax อย่างไรหรอครับ

<script language="javascript" type="text/javascript">
function Inint_AJAX() {
   try { return new ActiveXObject("Msxml2.XMLHTTP");  } catch(e) {} //IE
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} //IE
   try { return new XMLHttpRequest();          } catch(e) {} //Native Javascript
   alert("XMLHttpRequest not supported");
   return null;
};function calculate() {
     var req = Inint_AJAX();
     req.onreadystatechange = function () {
          if (req.readyState==4) {
               if (req.status==200) {
                    var area = document.getElementById('divcal');
                    area.innerHTML = req.responseText;
               }
          }
          else {
                  var area = document.getElementById('divcal');
                area.innerHTML = "<img src=images/indicatp.gif>";
        }
     };

    //dml=document.formlist ;
    // get the number of elements from the document
    len = document.formlist.numrow.value;
       
    for( i=0 ; i<len ; i++)
    {
    var _cartID = document.formlist._cartID[i].value;
    var _price = document.formlist._price[i].value;
    var _discount = document.formlist._discount[i].value;
    var count = document.formlist.count[i].value;    
     }
     req.open(    "GET", "ajax/cart_cal.php?_cartID=" + _cartID+"&_price="+_price+"&_discount="+_discount+"&count="+count , true);
     
     req.send(null); //ส่งค่า
}
</script>

 

โดยค่าที่ส่งไปจะมาจาก From โดยชื่อฟอร์ม = formlist

และคิวรี่ค่าออกมาโดยใช้ while loop และให้วนลูป textbox โดยตั้งชื่อเป็น Array ดังนี้

  <input type="hidden" name="_cartID[]"  value="<?=$row_list["cart_id"];?>" />
  <input type="hidden" name="_price[]" value="<?=$row_list["price"];?>" />
  <input type="hidden" name="_discount[]" value="<?=$row_list["discount"]?>" />

จะทำอย่างไรให้ส่งค่าไปอีกไฟล์นึง โดยใช้ Ajax เป็นตัวกลางส่งข้อมูลไป

ขอบคุณครับ

 

29 ต.ค. 2551 4 5,292

ดูใน how to เลยครับ ตอบให้แล้ว

#1

ขอบคุณมากครับ

#2

howto ไหนอ่า
#3

อ้างอิงจาก ความคิดเห็น #3howto ไหนอ่า
ค้นหาใน บทความ ดูเลยครับ คำตอบมัน 4 ปีมาแล้วครับ ในสมัยที่ผมใช้ชื่อบทความว่า howto
#4
ความคิดเห็น
ไฟล์อัปโหลด ชนิด jpg, jpeg ขนาดไฟล์ไม่เกิน 1024
^