<body> <form action="test.js"> <p><b>Ваше имя:</b><br> <input type="text" name="u_name" size="35"> <p><b>Каким браузером вы пользуетесь?</b><br> <input type="radio" name="t" value="moz">mozilla<br> <input type="radio" name="t" value="chr">chrome<br> <input type="submit"> </p> </form> </body>
This is the form itself.
if(t==chr){ alert(u_name + ", you're using chome") } else{ alert(u_name + ", you're using mozilla") }
This is the test.js
file. Why does the page with the code come out on the site after sending the form and no action takes place?
<script>
html tag, obviously. But even after that, it will not work, because you do not have the variablest
andchr
. Read javascript tutorials - andreymal 5:43 pm