i have a javascript onchange function on my select tag which when selected it sends the data to my php file and retruns it. i want the results to be displayed in a textbox with ID typid. all seems well. the function response returns data from the php file but for some reason its not displaying in my textbox. i tried to display in a span tag but still not working. kindly help. below is my function.
function getvalues(){
var select1 =document.getElementById('select1').value;
var datastring = 'select1='+select1;
$.ajax({
type:"POST",
url:"gettypid.php",
data:datastring,
dataType: 'Text',
cache:false,
success:function(html){
var k= html;
//$("#typid").html(html.responseText);
// alert(k);
$('#typid').HTML(html);
getvalues();
}
});
return false;
}
You should use .val()
function to set value.
$('#typid').val(html);
Form inputs have no html values so if you want to get or set the input text by using val() function.
function getvalues(){
var select1 = document.getElementById('select1').value;
var datastring = 'select1='+select1;
$.ajax({
type:"POST",
url:"gettypid.php",
data:datastring,
dataType: 'Text',
cache:false,
success:function(html){
$('#typid').val(html);
getvalues();
}
});
return false;
}