Hi,
Richard Rosser wrote:
Greetings.
I know not one word of Javascript and wondered if there was
an easy way to pre-populate a form field in a similar manner to
populating an eMail 'subject' field? -
The following populates the subject field in an eMail:
a href="mailto:me@anwhere.com?subject=USER ID 12345
This is not standard, and you have no guarantee that it will work
correctly...
How can I populate the first field of a form (or can I?) with the
same information - i.e. the USER ID located on the HTML page
calling the form?
Any help appreciated
Using HTML:
<input type="text" id="tfUserId" name="tfUserId" value="USERID" />
Using javascript
:
document.getElementById( "tfUserId" ).value = "USERID";
This code will throw an error if tfUserId doesn't exist, so a better
code would be:
if ( document.getElementById ) // This checks if the feature exists
{
var nField = document.getElementById( "tfUserId" );
if ( nField != null
&& nField.value != null )
{
nField.value = "USERID";
}
else
{
// No such field, handle error
}
}
else
{
// Browser doesn't support document.getElementById
}
HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering:
http://www.galasoft-LB.ch
Private/Malaysia:
http://mypage.bluewin.ch/lbugnion
Support children in Calcutta:
http://www.calcutta-espoir.ch