Toby said:
Willy said:
<input name=userInput type=text value="something">
Could value'something' ibe put in a variable via avascript?
<form name=theForm>
<input name=userInput type=text value="">
</form>
<script type="text/javascript">
var myInput = document.forms["theForm"].elements["userInput"];
myInput.value = "something";
</script>
Sorry -- I think I misread your question. My example above uses Javascript
to put something into a form field. It seems you want to read it *out*.
Here you have two options, depending on what you want to read. Say you
have '<input value="something">' but the visitor then types into the form
field 'something else'. Do you want to retrieve the original value
'something', or the new value 'something else'?
If you want to retrieve 'something else' (which most people would probably
want), then:
<form name=theForm>
<input name=userInput type=text value="something">
</form>
<script type="text/javascript">
var myInput = document.forms["theForm"].elements["userInput"];
var WhatIWant = myInput.value;
// now the variable 'WhatIWant' has what you want.
</script>
If you want to retrieve the original value ('something') then you need
'myInput.defaultValue' instead of 'myInput.value'.