View Full Version : Passing dup info from 1 text box to another on same form

06-26-2002, 02:37 PM
I have a form that will be used for incoming calls to Customer Service. On the form are text boxes for Callers info and Senders Info. If the caller IS the sender, I want the data entered into Callers info to show up in the Senders text boxes as soon as the data is entered. I am trying to use onBlur to call a function that checks if the caller is the sender. I can't get the data to show up in the Senders text boxes. Here is the function I have been trying to use followed by the HTML portion of the code. I call the function after the phone number is entered. (This is my first request for help--Please let me know if I can give better info)

function CallerIsSender() {
var iCallerFirst = document.forma.callerfirstname.value;
var iCallerLast = document.forma.callerlastname.value;
if (document.forma.requestor(0).checked == true)
document.forma.senderfirstname.value = document.forma.callerfirstname.value;

document.forma.senderlastname.value = document.forma.callerlastname.value;

<table align="center" border="0" cellspacing="0" cellpadding="2" width="700">
<td align="center" bgcolor="##CCFFFF">Callers Phone#: <br>
1 - (
<small><input type="text" onKeyUp="return autoTab(this, 3, event);" name="areacode" size="4" maxlength="3"></small>) -
<small><input type="text" onKeyUp="return autoTab(this, 3, event);" name="prefix" size="4" maxlength="3"></small> -
<small><input type="text" onBlur="return autoTab(this, 4, event);return CallerIsSender;" name="phonefour" size="5" maxlength="4"></small>

06-26-2002, 02:58 PM
well, with only the code that i have to look at here, i can't be sure, but i think that at least part of your problem is this:

if (document.form.requestor(0).checked == true)

that should be

if (document.form.requestor[0].checked == true)

also, i'm thinking you want both of these to happen, if the caller is the sender:
document.form.senderfirstname.value = document.forma.callerfirstname.value;
document.forma.senderlastname.value = document.forma.callerlastname.value;

but the second one looks like it will happen every time, because it's not inside of the if() statement. try writing it this way, instead:

if (document.form.requestor[0].checked == true) {
document.forma.senderfirstname.value = document.forma.callerfirstname.value;

document.forma.senderlastname.value = document.forma.callerlastname.value;

06-26-2002, 03:55 PM
I tried those changes, and the value is not passing to the Sender area. I thought there might be a way to "write" to the other text box "if condition is met"?

06-26-2002, 11:39 PM
This is a shortened version of what I'm using on an order form that auto-fills the shipping
section after the billing info, if the user clicks on the radio button.

Could this be adapted to your needs, with an onKeyUp function call via autotab?

<SCRIPT language="JavaScript">
<!-- Begin
var ShipName = "";
var ShipEmail = "";
var ShipPhone = "";
var ShipConfirm = 0;

function InitSaveVariables(form) {
ShipName = form.ShipName.value;
ShipEmail = form.ShipEmail.value;
ShipPhone = form.ShipPhone.value;
ShipConfirm = form.ShipConfirm.checked;

function ShipToBillPerson(form) {
if (form.copy.checked) {
form.ShipName.value = form.BillName.value;
form.ShipEmail.value = form.BillEmail.value;
form.ShipPhone.value = form.BillPhone.value;
form.ShipConfirm.checked = form.ShipConfirm.checked;
else {
form.ShipName.value = ShipName;
form.ShipEmail.value = ShipEmail;
form.ShipPhone.value = ShipPhone;
form.ShipConfirm.checked = ShipConfirm;
// End -->

....somewhere in the form

<input type="checkbox" name="copy" onclick="javascript:ShipToBillPerson(this.form);" value="checkbox">


Since you are using autoTAB, could you not choose at the end of your phone number,
instead of using onBlur, something like: onKeyUp="javascript:ShipToBillPerson(this.form);"

****This is just a sample of the onKeyDown/Up as far as how it jumps to the next field -- perhaps not necessary for point I'm trying to make, other than how to use onKeyUp*****

<br>Credit Card Number:&nbsp;&nbsp;&nbsp;
<input type="text" name="CC1" size="4" maxlength="4" onKeyDown="TabNext(this,'down',4)" onKeyUp="TabNext(this,'up',4,this.form.CC2)">&nbsp;-&nbsp;
<input type="text" name="CC2" size="4" maxlength="4" onKeyDown="TabNext(this,'down',4)" onKeyUp="TabNext(this,'up',4,this.form.CC3)">&nbsp;-&nbsp;

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum