keyongtech


  keyongtech > javascript > 08/2006

 #1  
08-24-06, 08:35 AM
Richard Rosser
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?subject=USER ID 12345

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
 #2  
08-24-06, 10:27 AM
Laurent Bugnion
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?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
 #3  
08-24-06, 11:39 AM
Richard Cornford
Laurent Bugnion wrote:
<snip>
> Using HTML:
>
> <input type="text" id="tfUserId" name="tfUserId" value="USERID" />

^

If this is HTML what is that slash doing at the end of the INPUT tag?

Richard.
 #4  
08-24-06, 12:39 PM
Tom Cole
Richard Cornford wrote:
> Laurent Bugnion wrote:
> <snip>
> > Using HTML:
> >
> > <input type="text" id="tfUserId" name="tfUserId" value="USERID" />

> ^
>
> If this is HTML what is that slash doing at the end of the INPUT tag?


Stop it. You're going to confuse the newbies.
 #5  
08-24-06, 01:02 PM
Richard Cornford
Tom Cole wrote:
> Richard Cornford wrote:
>> Laurent Bugnion wrote:
>> <snip>
>>> Using HTML:
>>>
>>> <input type="text" id="tfUserId" name="tfUserId" value="USERID" />

>> ^
>>
>> If this is HTML what is that slash doing at the end of the INPUT tag?

>
> Stop it. You're going to confuse the newbies.


I am not the one posting XHTML mark-up and labelling it HTML.

Richard.
 #6  
08-24-06, 01:07 PM
Laurent Bugnion
Hi,

Richard Cornford wrote:
> Laurent Bugnion wrote:
> <snip>
>> Using HTML:
>>
>> <input type="text" id="tfUserId" name="tfUserId" value="USERID" />

> ^
>
> If this is HTML what is that slash doing at the end of the INPUT tag?
>
> Richard.


Do you eat a validator for breakfast every morning? ;-)

Laurent
Similar Threads
Populate subform field on Afterupdate of main form field

I have a combo box in a main form. On afterupdate, I need to compare the selection with data in a field on the subform and then populate another field on the subform with a...

Populate subform field with 2 digits of main form field

I would like to populate a field (txtDC) on a subform with the first 2 digits of a field (cboStore) on the main form. Thanks in advance!

Populate Company field from Contact field in custom task form

Using Outlook 2002 or 2003, creating a custom Outlook form based on the Outlook default Task form. On page 2, I want to select a contact from the Contacts folder. Then, I...

Populate subform field from main form field

Hello, I have an OrderDate date field on my main form. I have a subform linked to it that has a column called TransactionDate. I want to put the OrderDate from the main...

Creating a multiselect field in a form to populate a single field in a table

Am wanting to include a single input field where multiple selections are possible (checkboxes) and have this populate a single field in the table. This field in the table...


All times are GMT. The time now is 03:31 PM. | Privacy Policy