Ajax获取文本框的名称和值,并将它们传递给update.php [英] Ajax get name and value of textbox and pass them to update.php

查看:49
本文介绍了Ajax获取文本框的名称和值,并将它们传递给update.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要ajax脚本来获取正在编辑的文本框的名称和值,并将它们传递给update.php我现在已经搜索了几周但找不到答案,我是ajax的新手。< br $>








Hi, i need the ajax script to pick up the name and value of the textbox being edited, and pass them to update.php i have been searching for weeks now and cannot find an answer, i am new to ajax.




<script type='text/javascript'>

function updateqty(this) { 

   itemname = $(this).attr('name').slice(9, -1);
   itemqty = $(this).value;  


    if (window.XMLHttpRequest) {
        xmlhttp1 = new XMLHttpRequest();
    }
    xmlhttp1.onreadystatechange = function () {
        if (xmlhttp1.readyState == 4 && xmlhttp.status == 200) {
            document.getElementById("cart1").innerHTML = xmlhttp1.responseText;
        }
    }
    alert(itemname);
    xmlhttp1.open("GET", "php/updateqty.php?order=238&id=" + itemname + "&qty=" + itemqty, true);
    xmlhttp1.send();
}




</script> 










<div id="cart1">

   <table id='POITable' width='100%' border='1'>
        <tr>
            <td>SKU</td>
            <td>QTY</td>
            <td width='45%'>item</td>
            <td>Unit Price</td>
            <td>Line Price</td>
            <td>Delete</td>
        </tr><tr><td>99966</td><td>

<input type='text' name='quantity[779]' size='3' value='3' tabindex='1' onblur='updateqty(this)' />

</td><td>Dewalt Work Boots size 9</td><td>24.99</td><td>74.97</td><td><img src='images/btn_delete.png'  önclick='deleteRow(this)' height='30'/></td>
<tr><td>10004</td><td>

<input type='text' name='quantity[778]' size='3' value='1' tabindex='1' onblur='updateqty(this)' />

</td><td>Work Hat</td><td>2.45</td><td>2.45</td><td><img src='images/btn_delete.png'  önclick='deleteRow(this)' height='30'/></td>
<tr><td>10192</td><td>

<input type='text' name='quantity[777]' size='3' value='1' tabindex='1' onblur='updateqty(this)' />

</td><td>Dickies Work Trousers 30/32</td><td>19.99</td><td>19.99</td><td><img src='images/btn_delete.png'  önclick='deleteRow(this)' height='30'/></td>
<tr><td>10101</td><td>

<input type='text' name='quantity[776]' size='3' value='1' tabindex='1' onblur='updateqty(this)' />

</td><td>Garden Tap Kit</td><td>9.99</td><td>9.99</td><td><img src='images/btn_delete.png'  önclick='deleteRow(this)' height='30'/></td>
</div>







任何有关此事的帮助将不胜感激



提前致谢




Any help on this matter would be greatly appreciated

Thanks in advance

推荐答案

this ).attr(' name')。slice( 9 , - 1);
itemqty =
(this).attr('name').slice(9, -1); itemqty =


this )。value;


if window .XMLHttpRequest){
xmlhttp1 = new XMLHttpRequest();
}
xmlhttp1.onreadystatechange = function (){
if (xmlhttp1.readyState == 4 && xmlhttp.status == 200 ){
document .getElementById( cart1 ).innerHTML = xmlhttp1.responseText;
}
}
alert(itemname);
xmlhttp1.open( GET php / updateqty.php?order = 238& id = + itemname + & qty = + itemqty, true );
xmlhttp1.send();
}




< / script>
(this).value; if (window.XMLHttpRequest) { xmlhttp1 = new XMLHttpRequest(); } xmlhttp1.onreadystatechange = function () { if (xmlhttp1.readyState == 4 && xmlhttp.status == 200) { document.getElementById("cart1").innerHTML = xmlhttp1.responseText; } } alert(itemname); xmlhttp1.open("GET", "php/updateqty.php?order=238&id=" + itemname + "&qty=" + itemqty, true); xmlhttp1.send(); } </script>










<div id="cart1">

   <table id='POITable' width='100%' border='1'>
        <tr>
            <td>SKU</td>
            <td>QTY</td>
            <td width='45%'>item</td>
            <td>Unit Price</td>
            <td>Line Price</td>
            <td>Delete</td>
        </tr><tr><td>99966</td><td>

<input type='text' name='quantity[779]' size='3' value='3' tabindex='1' onblur='updateqty(this)' />

</td><td>Dewalt Work Boots size 9</td><td>24.99</td><td>74.97</td><td><img src='images/btn_delete.png'  önclick='deleteRow(this)' height='30'/></td>
<tr><td>10004</td><td>

<input type='text' name='quantity[778]' size='3' value='1' tabindex='1' onblur='updateqty(this)' />

</td><td>Work Hat</td><td>2.45</td><td>2.45</td><td><img src='images/btn_delete.png'  önclick='deleteRow(this)' height='30'/></td>
<tr><td>10192</td><td>

<input type='text' name='quantity[777]' size='3' value='1' tabindex='1' onblur='updateqty(this)' />

</td><td>Dickies Work Trousers 30/32</td><td>19.99</td><td>19.99</td><td><img src='images/btn_delete.png'  önclick='deleteRow(this)' height='30'/></td>
<tr><td>10101</td><td>

<input type='text' name='quantity[776]' size='3' value='1' tabindex='1' onblur='updateqty(this)' />

</td><td>Garden Tap Kit</td><td>9.99</td><td>9.99</td><td><img src='images/btn_delete.png'  önclick='deleteRow(this)' height='30'/></td>
</div>







Any help on this matter would be greatly appreciated



Thanks in advance




Any help on this matter would be greatly appreciated

Thanks in advance


change all this to something else

change all this to something else
function updateqty(element) { 
 
   itemname =


这篇关于Ajax获取文本框的名称和值,并将它们传递给update.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆