problem in sending a ajax variable in to php variable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vivekgs2007
    New Member
    • Mar 2010
    • 62

    #1

    problem in sending a ajax variable in to php variable

    Hi to all,
    I am new to Ajax. I have a application form. which has a edit option of the previous record of a user.
    when a user select the date at which he wants to edit the records.then the ajax function calls performs the operation and gives the result...its all working properly...but the ajax response is dispalyed in only in text box not in drop down list...please help me around this..
    Ajax code is
    Code:
    	function ajaxFunction()
    	{ 
    
    		var student_id=document.frmMedicaldetail.student_id.value;
            var grade=document.frmMedicaldetail.grade.value;
    		var ajaxRequest; // The variable that makes Ajax possible!
    		try
    		{
    			ajaxRequest = new XMLHttpRequest();
    		} 
    		catch (e)
    		{
    			try{
    			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
    			} 
    			catch (e) 
    			{
    				try{
    				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
    			}
    			catch (e)
    			{
    				alert("Your browser broke!");
    				return false;
    			}
    			}
    		}
    
    			ajaxRequest.onreadystatechange = function()
    			{
    				if(ajaxRequest.readyState == 4)
    				{
    										
    					var ajaxDisplay = ajaxRequest.responseText;
    					//document.frmMedicaldetail.edit_age.value = edit_sick;
    					data = ajaxDisplay.split ( "<br/>" );
    					document.frmMedicaldetail.age.value = data[0];
    
    				}
    			}
    
    			var edit_date =  document.getElementById('edit_date').value;
    
    			if(grade!="" && student_id!="" && edit_date!="")
    			{  
    				var queryString = "?grade=" + grade + "&student_id=" + student_id + "&edit_date=" + edit_date;
    				ajaxRequest.open("POST","sick_ajax.php"+queryString,true);
    				ajaxRequest.send(null);
    			}		
    
    	
    	}
    It is displayed in the input box
    Code:
    <input type='text' name='age' value=''>
    Not in Drop down box
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    but the ajax response is dispalyed in only in text box not in drop down list
    this is because in the readystatechang e handler you only change the textbox.

    Comment

    • vivekgs2007
      New Member
      • Mar 2010
      • 62

      #3
      Originally posted by Dormilich
      this is because in the readystatechang e handler you only change the textbox.
      So What I have to do..please help

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        include the dropdown update in the handler (currently I can say nothing about how to do that, because I don’t know your code).

        Comment

        Working...