Hi,
I’ve created a piece of javascript which calculates the sunrise/sunset time for any day inputted into a form. If I include the document.write() statement inside the function which performs the calculation, when I press submit on the form, the answer is displayed but the input form itself disappears.
This example code shows what I mean:
[code=html]
<html>
<head>
<script type=”text/javascript”>
function display(){
var text = document.form1.text1.value;
document.write(text);
}
</script>
</head>
<body>
<form name = “form1”>
<input type = “text” name = “text1”>
<input type = “button” value = “click” onClick = “display()”>
</form>
</body>
</html>
If I put the document.write() statement outside of the form then the result will only be displayed when the page is refreshed. What I’ve been trying to do is to keep the onClick event handler sending the information through the function instead of simply refreshing the page and then displaying it alongside the input form. I have however been unable to achieve this.
Any help would be appreciated.
Allan