繁体   English   中英

如何使用ajax在文本框中返回值?

[英]how to return value in textbox using ajax?

当我选择下拉值时,它会给我价格,但会删除所有之前的值。
在ajax代码下执行后,如何返回产品名称和下拉值? 函数refresh_load是一个ajax函数。

enter code here
 <div class="product_sub"><input type="text" name="prod[]" id="prod0" size="30" class="input_box" onkeyup="autocomp()"/><input type="hidden" name="txt_pid[]" id="txt_pid0" /></div>
            <div class="product_sub"><select name="price" id="price" class="input_box" onchange="refresh_load()"><option value="">Select</option>
            <option id="billing_price" value="Billing Price">Billing Price</option>
            <option id="selling_price" value="Selling Price">Selling Price</option></select></div>

 <script type="text/javascript">
    function refresh_load()     
{
 //alert('hi');
 var price=document.getElementById('price').value; 
 var prodid=document.getElementById('txt_pid0').value; 

 var xmlhttp;       
    if (window.XMLHttpRequest)
     {
        xmlhttp=new XMLHttpRequest();
     }
    else
    {
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function()
    {
        if(xmlhttp.readyState==4 && xmlhttp.status==200)
            {   
                //alert(xmlhttp.responseText);
                //document.images['imgtrue1'].src="../images/"+xmlhttp.responseText.split("#t#")[0];
                document.getElementById("rate").value=xmlhttp.responseText;
            }
    }           
        //xmlhttp.open("GET","ref_cat_class.php?val="+val+"&val2="+val2,true);
        //alert(p);     
            xmlhttp.open("GET","refresh_page.php?price="+price+"&prodid="+prodid,true);
            xmlhttp.send();
            //alert('hiii');

               document.getElementById("frmmonthly").reset();           
}
</script>

函数刷新负载有这条线,

document.getElementById("frmmonthly").reset();

正在重置您的表单值。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM