Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-18-2005, 02:04 PM   PM User | #1
kraftomatic
Regular Coder

 
Join Date: Jul 2003
Posts: 593
Thanks: 16
Thanked 0 Times in 0 Posts
kraftomatic is an unknown quantity at this point
Automatically Populating One Field With Another?

Hey Guys,

Question - I've got a form with these 2 fields: "for" and "ship to". When the user enters data for the "for" field (something like this):

Name of Company
Address of Company
City, State, Zip

After they tab onto the next field, how can I get that data to automatically populate in the "ship to" box? Currently both of these fields are textareas.

Thanks much.
kraftomatic is offline   Reply With Quote
Old 03-18-2005, 03:23 PM   PM User | #2
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
Something like this?:
PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd">
<
html>
<
head>
<
title>Untitled Document</title>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<
meta http-equiv="Content-Style-Type" content="text/css">
<
meta http-equiv="Content-Script-Type" content="text/javascript">
</
head>
<
body>
<
form>
<
textarea name="t1" cols="30" rows="3" onkeyup="this.form.elements['t2'].value=this.value"></textarea>
<
textarea name="t2" cols="30" rows="3"></textarea>
</
form>
</
body>
</
html
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Kor is offline   Reply With Quote
Old 03-18-2005, 03:33 PM   PM User | #3
kraftomatic
Regular Coder

 
Join Date: Jul 2003
Posts: 593
Thanks: 16
Thanked 0 Times in 0 Posts
kraftomatic is an unknown quantity at this point
Nice .. . I just came up with:

// copies forField into shipTo field
function ForToShipTo() {
var val3 = document.myForm.forField.value;
document.myForm.shipTo.value = val3;
}

<textarea name="forField" class="textbox" rows="5" cols="60" onblur="ForToShipTo()"></textarea>
<textarea name="shipTo" class="textbox" rows="5" cols="70"></textarea>

Same thing it looks like, only yours does it on the fly.

Thanks for the help.
kraftomatic is offline   Reply With Quote
Old 03-18-2005, 04:08 PM   PM User | #4
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
I often try to avoid direct (name,id) referenceing by using either this self reference (with variants this.form, this.value, this.parentNode, this.getElementsByTagName(tagname)[index] ... and so on). It makes the code more useful and dynamic...
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Kor is offline   Reply With Quote
Old 03-18-2005, 04:14 PM   PM User | #5
kraftomatic
Regular Coder

 
Join Date: Jul 2003
Posts: 593
Thanks: 16
Thanked 0 Times in 0 Posts
kraftomatic is an unknown quantity at this point
True .. that would be helpful with my next issue.

http://www.codingforums.com/showthread.php?t=54753

Any ideas?

Thanks.
kraftomatic is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:01 PM.


Advertisement
Log in to turn off these ads.