Forum Home
Press F1
 
Thread ID: 39102 2003-10-27 20:09:00 JavaScript question aNtzy (4070) Press F1
Post ID Timestamp Content User
187070 2003-10-27 20:09:00 It's more of a "how data is displayed" problem. I'm just learning how to write JavaScripts and what I would like to do is have a message display on the currently active page without resorting to annoying "alerts" or the possibility of the user messing with the message using input boxes. I've come up with a small peice of JavaScript to demonstrate what I mean. Hope that's appropriate:


<!-- Author: aNtzy

Date: 28th October 2003

Purpose: To demonstrate the problem I'm having. I'm trying to dump a value, which is provided by the user, to the currently active page when the user hits the button.

Bugs: The only one that really concerns me at the moment. When the user clicks the button the input displayed is not printed just below the button which is what I want. What can I do to stop this from happening without resorting to alerts and input boxes to display the value.
-->

<html>
<head>
<title>Demonstration</title>

<script language="JavaScript">
<!-- Hide me

/* input entered by user is passed to the function and the value displayed */

function display_Input(x){
document.writeln(x);
}
//Show me-->
</script>

</head>
<body>
<form name="a_Form">


<input
name="user_Input"
value="20"
size="20">


<input
type="button"
value="Click here"
onClick="display_Input(document.a_Form.user_Input.value)">


</form>
</body>
</html>

When I previewed this the formatting looked kinda funny, sorry about that.

- aNtzy.
aNtzy (4070)
1