kraftomatic
03-18-2005, 02:04 PM
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.
Something like this?:
<!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>
kraftomatic
03-18-2005, 03:33 PM
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.
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...
kraftomatic
03-18-2005, 04:14 PM
True .. that would be helpful with my next issue.
http://www.codingforums.com/showthread.php?t=54753
Any ideas? :)
Thanks.