[ILUG] Using JS to set a default Value for an HTML field element?

Martin Feeney martin at tuatha.org
Thu Feb 23 17:46:08 GMT 2006


Braun Brelin wrote:
> Hi all,
> 
> Is it somehow possible to do the following:
> 
> <input type="textarea" value="Javascript:set_value_function()">
> 
> ?
> 
> Obviously, the above doesn't work (or seem to, at any rate) but is there a way
> to set a textarea value or defaultValue to something other than a static string?

<body onload="set_value_function()">

The have the set_value_function() you define set the value of the 
textarea, which you'll now have to name or set an id on, depending on 
which set of standards you wish to follow.

If the page is generated from php or any other server-side script, the 
answer is more obvious and a lot easier.

Martin.



More information about the ILUG mailing list