This may be ok, I use onkeypress to disable the code Charlie used. He
is right though, jQuery would make this a bit slimmer. :)
I was about to hit send but... to be 100% anal, even this isn't
perfect. onkeypress will fire on ANY key press, so I may modify
profile name to add A and then delete A, and in theory I haven't
changed. I doubt you care about that though?
<input type="text" name="First_name" id="firstName"
onblur="fillProfile()"/><br/>
<input type="text" name="Last_name" id="lastName" onblur="fillProfile()" /><br/>
<input type="text" name="Profile_name" id="profileName"
onkeypress="disableIt()"/>
<script>
var doit=true
function disableIt() {
doit=false
}
function fillProfile() {
if (doit) {
document.getElementById('profileName').value =
document.getElementById('firstName').value +
document.getElementById('lastName').value;
}
}
</script>
On Sun, May 31, 2009 at 4:38 PM, Raymond Camden <[email protected]> wrote:
> Of course, if the user enters their last name first there, it won't work. ;)
>
> On Sun, May 31, 2009 at 4:36 PM, Charlie Griefer
> <[email protected]> wrote:
>>
>> On Sun, May 31, 2009 at 2:24 PM, Rick Jensen <[email protected]> wrote:
>>
>>>
>>> Summary: I am trying to autofill an input field based on the values of two
>>> other fields.
>>>
>>> Detail: I have two input fields called First_name and Last_name. I have a
>>> third field called Profile_name. I want to fill in the Profile_name to equal
>>> the value of the first two fields automatically when you lose focus on each
>>> of First_name and Last_name field.
>>>
>>> The new value of the Profile_name is a suggestion and the user may choose
>>> to overwrite it. If they go back and update the First_name and Last_name
>>> fields after the fact, I don't want to update the Profile_name field again.
>>>
>>
>> <input type="text" name="First_name" id="firstName" />
>> <input type="text" name="Last_name" id="lastName" onblur="fillProfile();" />
>>
>> <input type="text" name="Profile_name" id="profileName" />
>>
>> <script>
>> function fillProfile() {
>> if (document.getElementById('profileName').value == "") {
>> document.getElementById('profileName').value =
>> document.getElementById('firstName').value +
>> document.getElementById('lastName').value;
>> }
>> }
>> </script>
>>
>>
>
--
===========================================================================
Raymond Camden, ColdFusion Jedi Master
Email : [email protected]
Blog : www.coldfusionjedi.com
AOL IM : cfjedimaster
Keep up to date with the com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know
on the House of Fusion mailing lists
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323015
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4