I am trying to build an app that will alert users full name and age category from young, average, and old age but no matter which age i type in it says "You belong to young category". Please tell me what is wrong with my code. Here it is:
<script type="text/javascript">
var godine = 25;
var starost;
if (godine < 30) {
starost = " Vi pripadate u kategoriju mladih.";
}
if ((godine >= 30) && (godine < 70)) {
starost = " Vi pripadate u kategoriju srednje starih.";
}
if (godine > 70) {
starost = " Vi pripadate u kategoriju starih";
}
</script>
<h1>Dobro dosli na kategorisanje starosti</h1>
<form action="" name="frmLogin" onsubmit="alert('Korisnice: ' + ' ' + document.frmLogin.txtIme.value + ' ' + document.frmLogin.txtPrezime.value + document.frmLogin.txtStarost.value + starost)">
Korisnicko ime: <input type="text" name="txtIme"/>
<br>
Korisnicko prezime: <input type="text" name="txtPrezime">
<br>
Godine: <input type="text" name="txtStarost">
<br>
<input type="submit" value="Pokreni program">
</form>
Aucun commentaire:
Enregistrer un commentaire