Posted by Toby Inkster on 11/15/06 09:45
Willy wrote:
> <input name=userInput type=text value="something">
> Could value'something' ibe put in a variable via avascript?
Yes.
<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>
Note: I've given the form a name here. You don't need to -- you could
refer to it by number (the first form on the page is 'document.forms[0]',
the next one is 'document.forms[1]', etc), but numbers can accidentally
change when you rearrange your page next month.
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
[Back to original message]
|