how can i write a code when user write name in the textbox and click the button that alert ("I m "+ namefunction) example onClick and window alert ==>>> I m Emirhan , please help me and if you want show my trials its :
You are expecting showType to return some kind of value, so that you can assign it to the innerHTML property of getElementById(‘result’). The problem is, your function does not explicitly return a value, so by default it returns the value undefined. Your function only console.logs the values of the variables x, y, and z. If you want to have the innerHTML display a string showing the values of variables x, y, and z, then you will need to return such a value.
<script>
var x,y,z;
x="";
y=5;
z=3.5;
function showType() {
if(x===String;) {
document.write("x is a string");
}
getElementById('result').innerHTML=showType();
}
</script>