Jump to content


onBlur - copy value in one field to another

  • Please log in to reply
1 reply to this topic

#1 AndieB

  • Members
  • PipPipPip
  • Advanced Member
  • 77 posts
  • LocationSweden
  • Age:37

Posted 08 September 2006 - 07:28 AM

Hi alla Javascript Gurus!

I have question regarding Javascript, since I'm very newbie to it.

The thing is that I do have a <form> with <input> fields in it.
I would like the function to be like this:

When leaving the first <input> field, with the help of <onblur> I want the value/text written in that input-field to be copied into the next <input> field.

How do I do this?

Here is my code:
<form action="page.html" method="post" >
Say it: <input type="text" size="15" maxlength="13" name="field1" />
<br />
You wrote: <input type="text" size="15" name="field2" />

Anyone who can help me out?

Thank you,

" Start by looking in the mirror before pointing the finger outwards... "
" Nothing can be, until it has passed your mind... "

#2 radalin

  • Members
  • PipPipPip
  • Advanced Member
  • 179 posts

Posted 08 September 2006 - 10:10 AM

Say it: <input type="text" size="15" maxlength="13" id="field1" name="field1" onBlur="field2.value=this.value;" />
<br />
You wrote: <input type="text" size="15" name="field2" id="field2" />

and it's done. I have put id's on them so do not miss that.
Roy Simkes
Yet Another Parkyeri Developer

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users