04-04-2023, 07:54 AM
The HTML part between the <body></body> tags looks like this:
The JavaScript part looks like this:
Note: The reset button and the reset function are optional in case you want to delete what you were looking for in order to look for something else.
Code:
Enter the first number here:
<br>
<input type="Text" id="Num1">
<br>
Enter the second number here:
<br>
<input type="Text" id="Num2">
<br>
<input type="button" id="submit" value="submit" onclick="SwapNumbers()"></input>
<p id="Output"></p>
<input type="button" id="reset" value="Reset" onclick="Reset()"></input>
The JavaScript part looks like this:
Code:
function SwapNumbers()
{
Num1 = document.getElementById("Num1").value;
Num2 = document.getElementById("Num2").value;
Num3 = Num1;
Num4 = Num2;
Output = "You have entered " + Num4 + " and " + Num3;
document.getElementById("Output").innerHTML = Output;
}
function Reset()
{
document.getElementById("Num1").value = "";
document.getElementById("Num2").value = "";
document.getElementById("Output").innerHTML = "";
}
Note: The reset button and the reset function are optional in case you want to delete what you were looking for in order to look for something else.
Also follow me on Youtube for videos about video games:
https://www.youtube.com/channel/UCxfkGVU...2mQ/videos
https://www.youtube.com/channel/UCxfkGVU...2mQ/videos