PDA

View Full Version : Very simple script check...



divtag33
10-03-2006, 11:31 AM
Hi I'm very new to all this stuff, so if someone could help I'd be most appreciative!

I'm trying to write a test script that will get the number entered into a field and print it onscreen using identifiers - unfortunately the below doesn't work - can anyone point out where I'm being stupid - I've seen scripts using ["name_of_element"] to identify the exact part they want, but it doesn't work for me! :rolleyes:

<head>
<script language="JavaScript">
var main_variable = new Number();

function printVariables()
{
document.write(document.["test"].value);
}
</script>
</head>

<body>
<input type="text" name="test"><br>
<input type="submit" value="Show Numbers" onClick="printVariables()">
</body>

divtag33
10-03-2006, 11:44 AM
Ok I've given up on that method and I've got it 'sort of' working using getElementById - however it prints to a new page (ie my buttons/text boxes disappear - so I've tried to specify the location into a table at the bottom like below - but it still doesn't work - can anyone explain my stupidity?

<head>
<script language="JavaScript">
var main_variable = new Number();

function printVariables()
{
document.getElementById("main_app_gross_inc_show").write(document.getElementById("main_app_gross_inc").value);
}
</script>
</head>

<body>
<input type="text" id="main_app_gross_inc"><br>
<input type="submit" value="Show Numbers" onClick="printVariables()">

<div>
<table>
<tr>
<td id="main_app_gross_inc_show"></td>
</tr>
</table>
</div>
</body>