Jestem zielony jeśli chodzi o javascript.
Mam takie pytanie jak wypisać wynik na stronie z dwóch liczb które podaje uzytkownik do pola tekstowego po wciśnięciu przycisku?
Tutaj mój kod:
Kod
<!DOCTYPE html>
<html>
<body>
<head><title>Matematyka</title><META HTTP-EQUIV=content-type CONTENT=text/html; charset=iso-8859-2></head>
<form>
<input type="text" name="1" id="1"/>+
<input type="text" name="2" id="2"/>=
<input type="text" name="3" id="4"/>
<input type="button" id="5" name="button" value="Wykonaj">
</form>
<script type="text/javascript">
var zmienna1=document.getElementById("1").value;
var zmienna2=document.getElementById("2").value;
function wypisz() {
document.getElementById('3').zmienna1+zmienna2.value;
}
document.getElementById('5').onclick = wypisz()
</script>
</body>
</html>
<html>
<body>
<head><title>Matematyka</title><META HTTP-EQUIV=content-type CONTENT=text/html; charset=iso-8859-2></head>
<form>
<input type="text" name="1" id="1"/>+
<input type="text" name="2" id="2"/>=
<input type="text" name="3" id="4"/>
<input type="button" id="5" name="button" value="Wykonaj">
</form>
<script type="text/javascript">
var zmienna1=document.getElementById("1").value;
var zmienna2=document.getElementById("2").value;
function wypisz() {
document.getElementById('3').zmienna1+zmienna2.value;
}
document.getElementById('5').onclick = wypisz()
</script>
</body>
</html>