how print record from database when user select options from Dropdown menu? dynamic program

后端 未结 1 807
死守一世寂寞
死守一世寂寞 2021-01-25 08:55

i\'m trying to write code when user which selects specific option from Dropdown menu then after selecting specific option. value gets printed next to dropdown menu. That value i

1条回答
  •  情书的邮戳
    2021-01-25 09:11

    When you print your select box,you can passed parameter onChange="sendInfo(this.value);" function like below :

    $('
      

    ').appendTo('#container');

    Now in your sendInfo function do like below :

            function sendInfo(str)//str will have value selected from dropdown list   
                    {  
                       //attaching this value in url
                        var url="process.jsp?val="+str;  
                       if(window.XMLHttpRequest)
                        {  
    
                            request=new XMLHttpRequest();  
                        }  
                        else if(window.ActiveXObject)
                        {  
                            request=new ActiveXObject("Microsoft.XMLHTTP");  
                        }  
    
    
                            request.onreadystatechange= function() {
                if (this.readyState == 4 && this.status == 200) {
                    document.getElementById("amit").innerHTML = this.responseText;
                   }
                }; 
                            request.open("GET",url,true);  
                            request.send();  
                       } 
    

    Also don't forget to add div with id amit.Now ,if you select Type B then, val will have value TypeB ,use this in your select query and sent result back to your jsp page.

    0 讨论(0)
提交回复
热议问题