PDA

View Full Version : javascript



jetalomar
March 19th, 2004, 11:09
what is wrong with this code. This is what is happening when i click on the radio button is display the message on a new page and I want it to display in the same page.

what AM I doing wrong?

here is the code

<html>
<head>
<script type="text/javascript">
function check(brow)
{
document.write("your broswer is " + brow);
}
</script>

</head>
<body>

<form>
Which browser is your favorite<br>
<input type="radio"
name="browser" onclick="check(this.value)"
value="Explorer">Microsoft Internet Explorer<br>

<input type="radio"
name="browser" onclick="check(this.value)"
value="Netscape">Netscape Navigator<br>


</form>
<script type="text/javascript">
check(browser);
</script>
</body>
</html>

kabatak
March 19th, 2004, 11:48
document.write(); writes to a new page. try this code, it uses the same idea that i said in your other topic.



<html>
<head>
<script type="text/javascript">
function check(brow)
{
document.getElementById('area').innerHTML = 'your broswer is' + brow;
}
</script>
</head>
<body>

<form>
Which browser is your favorite<br>
<input type="radio" name="browser" onclick="check(this.value)" value="Explorer">Microsoft Internet Explorer<br>
<input type="radio" name="browser" onclick="check(this.value)" value="Netscape">Netscape Navigator<br>
</form>

<div id="area"></div>

</body>
</html>

jetalomar
March 19th, 2004, 11:56
thanks a lot for your help. it worked