I cannot seem to get a piece of code to return a variable yet it will log the variable in the console just fine. The json data is returning correctly and every array value that I call is there, the only thing not working is return Html;
and I don't know why.
Code...
function Input(Type, Name, Other, Value){
var Html = '';
switch(Type) {
case 'Select':
var formData = {
'Type': Other,
'Options': Options
};
$.ajax({
url: './PHPAPI/GetSelect.php',
method: 'get',
data: formData,
dataType: 'json'
}).done(function (data) {
Html = "<select name='"+Name+"'>";
$.each(data['Result'], function(Key, Value) {
Html = Html + "<option value='"+Value['Value']+"'>"+Value['Option']+"</option>";
});
Html = Html + "</select>";
console.log(Html);
});
break;
case 'Number':
Html = "<input type='number' min='0' value='0' name='"+Name+"' step='0.01'>";
break;
case 'Text':
Html = "<input type='text' name='"+Name+"' value='"+Value+"'>";
break;
case 'Date':
Html = "<input type='date' value='0' name='"+Name+"' value='"+Value+"'>";
break;
case 'Time':
Html = "<input type='time' value='0' name='"+Name+"' value='"+Value+"'>";
break;
case 'DateTime':
Html = "<input type='datetime-local' value='"+Value+"' name='"+Name+"'>";
break;
case 'Duration':
Html = "<input type='range' min='0' max='100' value='0' name='"+Name+"' step='1'><output id='"+Name+"'>0</output>";
break;
case 'Phone':
Html = "<input type='phone' name='"+Name+"'>";
break;
case 'Email':
Html = "<input type='email' name='"+Name+"'>";
break;
case 'Password':
Html = "<input type='password' name='"+Name+"'>";
break;
case 'Submit':
Html = "<input type='submit' name='"+Name+"' value='Submit'>";
break;
case 'Checkbox':
Html = "<input type='checkbox' name='"+Name+"'>";
break;
case 'Radio':
Html = "<input type='radio' name='"+Name+"'>";
break;
case 'Button':
Html = "<button name='"+Name+"'>"+Value+"</button>";
break;
default:
Html = "<p>There was an issue with input selection Args(Type:"+Type+"|Name:"+Name+"|Other:"+Other+"|Value:"+Value+")</p>";
break;
}
return Html;
}