Question

autofill textboxes after updating ON with checkbox?

Asked by: pasaga

does anyone know how to code for the following?:

a user enters mailing address in textboxes on a form, and s/he enters ON for a checkbox that indicates that the physical address = mailing address, and then it fills the corresponding textboxes (physical address) automatically with the same information. it must be reversed when s/he unchecks the checkbox.

thanks in advance!

psg

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2003-10-14 at 12:16:51ID20766717
Tags

autofill

,

checkbox

,

does

,

forms

Topic

FrontPage-Expressions

Participating Experts
3
Points
125
Comments
17

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. autofill textbox with checkbox click
    I would like to fill a textbox with a quantity of 1 when a checkbox is clicked. Both controls are inside of a datagrid.

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: seanpowellPosted on 2003-10-14 at 13:00:12ID: 9549804

I use this frequently:


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Copy Fields</title>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
var ShipFirst = "";
var ShipLast = "";
var ShipEmail = "";
var ShipCompany = "";
var ShipAddress1 = "";
var ShipAddress2 = "";
var ShipCity = "";
var ShipState = "";
var ShipStateIndex = 0;
var ShipZip = "";
var ShipConfirm = 0;

function InitSaveVariables(form) {
ShipFirst = form.ShipFirst.value;
ShipLast = form.ShipLast.value;
ShipEmail = form.ShipEmail.value;
ShipCompany = form.ShipCompany.value;
ShipAddress1 = form.ShipAddress1.value;
ShipAddress2 = form.ShipAddress2.value;
ShipCity = form.ShipCity.value;
ShipZip = form.ShipZip.value;
ShipStateIndex = form.ShipState.selectedIndex;
ShipState = form.ShipState[ShipStateIndex].value;
ShipConfirm = form.ShipConfirm.checked;
}

function ShipToBillPerson(form) {
if (form.copy.checked) {
InitSaveVariables(form);
form.ShipFirst.value = form.BillFirst.value;
form.ShipLast.value = form.BillLast.value;
form.ShipEmail.value = form.BillEmail.value;
form.ShipCompany.value = form.BillCompany.value;
form.ShipAddress1.value = form.BillAddress1.value;
form.ShipAddress2.value = form.BillAddress2.value;
form.ShipCity.value = form.BillCity.value;
form.ShipZip.value = form.BillZip.value;
form.ShipState.selectedIndex = form.BillState.selectedIndex;
form.ShipConfirm.checked = form.BillConfirm.checked;
}
else {
form.ShipFirst.value = ShipFirst;
form.ShipLast.value = ShipLast;
form.ShipEmail.value = ShipEmail;
form.ShipCompany.value = ShipCompany;
form.ShipAddress1.value = ShipAddress1;
form.ShipAddress2.value = ShipAddress2;
form.ShipCity.value = ShipCity;
form.ShipZip.value = ShipZip;      
form.ShipState.selectedIndex = ShipStateIndex;
form.ShipConfirm.checked = ShipConfirm;
   }
}
//  End -->
</script>
<form method="post" action="" name="billform">
<table border="1" cellspacing="0" cellpadding="3" width="400">
  <tr>
    <td colspan=2 width="100%">Billing Information</td>
  </tr>
  <tr>
    <td>First Name:</td>
    <td><input type="text" size="15" maxlength="50" name="BillFirst"></td>
  </tr>
  <tr>
    <td>Last Name:</td>
    <td><input type="text" size="15" maxlength="50" name="BillLast"></td>
  </tr>
  <tr>
    <td>E-Mail:</td>
    <td><input type="text" size="15" name="BillEmail"></td>
  </tr>
  <tr>
    <td>Company:</td>
    <td><input type="text" size="25" maxlength="100" name="BillCompany"></td>
  </tr>
  <tr>
    <td>Address:</td>
    <td><input type="text" size="40" maxlength="35" name="BillAddress1"></td>
  </tr>
  <tr>
    <td></td>
    <td><input type="text" size="40" maxlength="35" name="BillAddress2"></td>
  </tr>
  <tr>
    <td>City:</td>
    <td><input type="text" size="25" maxlength="21" name="BillCity"></td>
  </tr>
  <tr>
    <td>State:</td>
    <td><select name="BillState">
    <option selected>
    <option value="AL">ALABAMA
    <option value="AK">ALASKA
    <option value="AZ">ARIZONA
    <option value="AR">ARKANSAS
    <option value="CA">CALIFORNIA
    <option value="CO">COLORADO
    <option value="CT">CONNECTICUT
    <option value="DE">DELAWARE
    <option value="FL">FLORIDA
    <option value="GA">GEORGIA
    <option value="HI">HAWAII
    <option value="ID">IDAHO
    <option value="IL">ILLINOIS
    <option value="IN">INDIANA
    <option value="IA">IOWA
    <option value="KS">KANSAS
    <option value="KY">KENTUCKY
    <option value="LA">LOUISIANA
    <option value="ME">MAINE
    <option value="MD">MARYLAND
    <option value="MA">MASSACHUSETTS
    <option value="MI">MICHIGAN
    <option value="MN">MINNESOTA
    <option value="MS">MISSISSIPPI
    <option value="MO">MISSOURI
    <option value="MT">MONTANA
    <option value="NE">NEBRASKA
    <option value="NV">NEVADA
    <option value="NH">NEW HAMPSHIRE
    <option value="NJ">NEW JERSEY
    <option value="NM">NEW MEXICO
    <option value="NY">NEW YORK
    <option value="NC">NORTH CAROLINA
    <option value="ND">NORTH DAKOTA
    <option value="OH">OHIO
    <option value="OK">OKLAHOMA
    <option value="OR">OREGON
    <option value="PA">PENNSYLVANIA
    <option value="RI">RHODE ISLAND
    <option value="SC">SOUTH CAROLINA
    <option value="SD">SOUTH DAKOTA
    <option value="TN">TENNESSEE
    <option value="TX">TEXAS
    <option value="UT">UTAH
    <option value="VT">VERMONT
    <option value="VA">VIRGINIA
    <option value="WA">WASHINGTON
    <option value="DC">WASHINGTON, D.C.
    <option value="WV">WEST VIRGINIA
    <option value="WI">WISCONSIN
    <option value="WY">WYOMING
    </select>
    <input type="text" size="10" maxlength="10" name="BillZip"></td>
  </tr>
  <tr>
    <td colspan=2 align=center><input type="checkbox" name="BillConfirm" selected> Send confirmation email via email</td>
  </tr>
  <tr>
    <td colspan=2 width="100%">Shipping Information (Check to use Billing Information: <input type="checkbox" name="copy" OnClick="javascript:ShipToBillPerson(this.form);" value="checkbox"> )</td>
  </tr>
  <tr>
    <td>First Name:</td>
    <td><input type="text" size="15" maxlength="50" name="ShipFirst"></td>
  </tr>
  <tr>
    <td>Last Name:</td>
    <td><input type="text" size="15" maxlength="50" name="ShipLast"></td>
  </tr>
  <tr>
    <td>E-Mail:</td>
    <td><input type="text" size="15" name="ShipEmail"></td>
  </tr>
  <tr>
    <td>Company:</td>
    <td><input type="text" size="25" maxlength="100" name="ShipCompany"></td>
  </tr>
  <tr>
    <td>Address:</td>
    <td><input type="text" size="40" maxlength="35" name="ShipAddress1"></td>
  </tr>
  <tr>
    <td></td>
    <td><input type="text" size="40" maxlength="35" name="ShipAddress2"></td>
  </tr>
  <tr>
    <td>City:</td>
    <td><input type="text" size="25" maxlength="21" name="ShipCity"></td>
  </tr>
  <tr>
    <td>State:</td>
    <td><select name="ShipState">
    <option selected>
    <option value="AL">ALABAMA
    <option value="AK">ALASKA
    <option value="AZ">ARIZONA
    <option value="AR">ARKANSAS
    <option value="CA">CALIFORNIA
    <option value="CO">COLORADO
    <option value="CT">CONNECTICUT
    <option value="DE">DELAWARE
    <option value="FL">FLORIDA
    <option value="GA">GEORGIA
    <option value="HI">HAWAII
    <option value="ID">IDAHO
    <option value="IL">ILLINOIS
    <option value="IN">INDIANA
    <option value="IA">IOWA
    <option value="KS">KANSAS
    <option value="KY">KENTUCKY
    <option value="LA">LOUISIANA
    <option value="ME">MAINE
    <option value="MD">MARYLAND
    <option value="MA">MASSACHUSETTS
    <option value="MI">MICHIGAN
    <option value="MN">MINNESOTA
    <option value="MS">MISSISSIPPI
    <option value="MO">MISSOURI
    <option value="MT">MONTANA
    <option value="NE">NEBRASKA
    <option value="NV">NEVADA
    <option value="NH">NEW HAMPSHIRE
    <option value="NJ">NEW JERSEY
    <option value="NM">NEW MEXICO
    <option value="NY">NEW YORK
    <option value="NC">NORTH CAROLINA
    <option value="ND">NORTH DAKOTA
    <option value="OH">OHIO
    <option value="OK">OKLAHOMA
    <option value="OR">OREGON
    <option value="PA">PENNSYLVANIA
    <option value="RI">RHODE ISLAND
    <option value="SC">SOUTH CAROLINA
    <option value="SD">SOUTH DAKOTA
    <option value="TN">TENNESSEE
    <option value="TX">TEXAS
    <option value="UT">UTAH
    <option value="VT">VERMONT
    <option value="VA">VIRGINIA
    <option value="WA">WASHINGTON
    <option value="DC">WASHINGTON, D.C.
    <option value="WV">WEST VIRGINIA
    <option value="WI">WISCONSIN
    <option value="WY">WYOMING
    </select>
    <input type="text" size="10" maxlength="10" name="ShipZip"></td>
  </tr>
  <tr>
    <td colspan=2 align=center>
    <input type="checkbox" name="ShipConfirm" selected> Send confirmation email via email</td>
  </tr>
</table>
</form>
</body>
</html>

 

by: coreybryantPosted on 2003-10-14 at 13:03:29ID: 9549828

You can do this:
<input type="checkbox" name="cbequal" onClick="javascript:{if(cbequal.checked){strShipFirst.value = strFirst.value; strShipFirst.readOnly = true; strShipLast.value = strLast.value; strShipLast.readOnly = true; strShipAddress.value = strAddress1.value; strShipAddress.readOnly = true; strShipCity.value = strCity.value; strShipCity.readOnly = true; strShipState.value = strState.value; strShipState.readOnly = true; strShipPostalCode.value = strPostalCode.value; strShipPostalCode.readOnly = true; strShipCountry.value = strCountry.value; strShipCountry.readOnly = true;} else {strShipFirst.value = ''; strShipFirst.readOnly = false; strShipLast.value = ''; strShipLast.readOnly = false; strShipAddress.value = ''; strShipAddress.readOnly = false; strShipCity.value = '';  strShipCity.readOnly = false; strShipState.value = '';  strShipState.readOnly = false; strShipPostalCode.value = '';  strShipPostalCode.readOnly = false; strShipCountry.value = ''; strShipCountry.readOnly = false;}}" value="ON">

and then just change the strShipFirst to the name of your shipping first name & strFirst to the name of your billing first name, etc.

Corey

 

by: pasagaPosted on 2003-10-14 at 13:46:46ID: 9550112

corey: i modified a bit to fit my page, but i think screwed it up can you check mine? fortunately, this code is not long as yours. is it the underlying scripting? my page is asp.

thanks so much! psg d

<input type="checkbox" name="chkMAILEQPHYS" onClick="javascript:{if(chkMAILEQPHYS.checked){txtMADDRESS1.value = txtPADDRESS1.value; txtMADDRESS1.readOnly = true; txtMADDRESS2.value = txtPADDRESS2.value; txtMADDRESS1.readOnly = true; txtMCITY.value = txtPCITY.value; txtMCITY.readOnly = true; cboMSTATE.value = cboPSTATE.value;cboMSTATE.readOnly = true;txtMZIP.value = txtPZIP.value;txtMZIP.readOnly = true;} else {strShipFirst.value = ''; strShipFirst.readOnly = false; {txtMADDRESS1.value = ''; txtMADDRESS1.readOnly = false; txtMADDRESS2.value = '';txtMADDRESS1.readOnly = false;txtMCITY.value = '';txtMCITY.readOnly = false; cboMSTATE.value = ''; cboMSTATE.readOnly = false; txtMZIP.value = ''; txtMZIP.readOnly = false;}" value="TRUE">

Mailing Address is same as Physical Address

 

by: seanpowellPosted on 2003-10-14 at 13:51:11ID: 9550138

I think you may have accepted the wrong answer - shall I have it changed over to Corey's code for you?

 

by: pasagaPosted on 2003-10-14 at 13:53:27ID: 9550151

sean: thanks for your reply. yes, please. the simpler the better. psg

 

by: seanpowellPosted on 2003-10-14 at 13:58:16ID: 9550205

I concur - I've posted a reqquest in CS for you - it won't take long.
http://www.experts-exchange.com/Community_Support/Q_20766831.html

Over to you Corey!

 

by: seanpowellPosted on 2003-10-14 at 14:05:44ID: 9550266

2 minutes? - I was thinking that you'd quit. Try and pick up the pace a little next time okay - we've got an image to keep up here.

(You're amazing)

 

by: coreybryantPosted on 2003-10-14 at 14:22:37ID: 9550377

Looking at it briefly - you left an strShipFirst in there..

-Corey

 

by: pasagaPosted on 2003-10-14 at 16:04:33ID: 9550894

c: i figured it out. missing a "}" at the end. now it autofills the mailing addy section. but i noticed that the value for the check is NOT being saved.  any clues? thanks. psg

 

by: coreybryantPosted on 2003-10-14 at 16:09:02ID: 9550905

The value for the checkbox?   The one that is making it populate the other fields?  Did you add chkMAILEQPHYS to the script so it would be added & a field to the database or on the confirm page?

-Corey

 

by: pasagaPosted on 2003-10-14 at 16:15:01ID: 9550942

hmm, doesn't the ... value="TRUE"... take care of that. should i add chkMAILEQPHYS.value=true as part of the script then? thanks again. p

 

by: coreybryantPosted on 2003-10-14 at 16:20:10ID: 9550960

Well I do not know if you are using Jmail or using a database, but for me to get a value on Jmail - I have to have every input on my confirmation listed.  And if you do not have the input listed then it will not be sent.  

So on your confirmation page that handles the data, you need to tell it do send the chkMAILEQPHYS value somewhere

-Corey

 

by: adilkhanPosted on 2003-10-14 at 20:34:31ID: 9552002

Do you want something like this?

<form method="POST" name="f1">
  <p><input type="text" name="t1" size="20">
  <input type="checkbox" name="C1" value="ON" onClick="if(this.checked){t2.value=t1.value};else{t2.value='101 Street'}"><br>
  <input type="text" name="t2" size="20"><br>
  <br>
  <input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>

101 Street is the Reserved Address.

 

by: coreybryantPosted on 2004-03-23 at 17:40:14ID: 10663690

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
PAQ / No Refund
Please leave any comments here within the next four days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

coreybryant
FP Page Editor

 

by: seanpowellPosted on 2004-03-24 at 04:07:04ID: 10666869

Corey - you answered the question { http:#9549828 }
Points to you on this one.

 

by: coreybryantPosted on 2004-03-24 at 04:11:26ID: 10666904

Thanks.  I guess I was sleeping or too many calls yesterday.  I'll post that when I get back.
-Corey

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...