Javascript trials

Javascript trials
0

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 :

<input type="text" id="text" value="name">
	<input type="button" onclick="greeting();" id="clickbutton" value="name">

</body>
<script type="text/javascript">
	function();
var btnName=document.getElementyById(('text').value)	;

var btnPerson=document.getElementyById('clickbutton');
btnPerson.onclick=function() {
	 alert("I'm" +btnName);
}



First you need to learn how to define a function. If you have not already, you should start by working through this challenge in our curriculum.

1 Like

i can define a function but i cant take an interaction it on html

Please show your updated code which includes a valid function definition that will make the changes you seek.

example a basic function

var x,y,z;
x="";
y=5;
z=3.5;
    function showType() {
    	console.log(x,y,z);
    }

so why there is a function (); in your code?

1 Like

yes i wrote it but i forgot to write there and so true writing should be like this:

var x,y,z;
x="";
y=5;
z=3.5;
function showType() {
console.log(x,y,z);
}
showType();

where can i get javascript coding task

so try again with showing your code without the broken function syntax


@Sylvester you can find the curriculum at freecodecamp.org/learn

1 Like
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8>
</head>
<body>

<div id="result">
</div>

</body>
<script>

var x,y,z;
x="";
y=5;
z=3.5;

function showType() {
console.log(x,y,z);

}
getElementById('result').innerHTML=showType();

</script>

</html>

did you mean writing job for javascript or joining a javascript project

or you want see javascript tags, if you want that:

<script>
/* there are 

*/
</script>

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.

1 Like
<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>

Why are you calling the function showType within the function showType?

I learned in this way on youtube i might learned wrong

You should probably go through the entire Free Code Camp Basic JavaScript section.

1 Like

writing job for javascript