473,494 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Using a Checkbox to populate another field

1 New Member
Hi all,

Trying to figure out how to use a checkbox in a form and have JavaScript populate another field. For instance, I have 2 fields:

DaytimePhone and EveningPhone and I have a checkbox that says "Check if evening phone is the same" and if you click that box, it should populate the evening field with the number entered in the DaytimePhone field. Does anyone know how to do that?
Sep 19 '06 #1
1 2269
acoder
16,027 Recognized Expert Moderator MVP
You can use onclick to call a function which populates the field, e.g.
Expand|Select|Wrap|Line Numbers
  1. <input type="checkbox" ... onclick="populate(this)">
Expand|Select|Wrap|Line Numbers
  1. function populate(checkbox) {
  2.     var daytime = document.getElementById("daytimeTel");
  3.     var evening = document.getElementById("eveningTel");
  4.     evening.value = daytime.value;
  5. }
You may also want to make use of the checked property of the checkbox so that the value is only copied if the checkbox is checked and not if it is unchecked.
May 13 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2111
by: claudel | last post by:
Hi I have a newb PHP/Javascript question regarding checkbox processing I'm not sure which area it falls into so I crossposted to comp.lang.php and comp.lang.javascript. I'm trying to...
5
10069
by: Deborah V. Gardner | last post by:
I would like to use "Yes" and "No" checkboxes on a subform. The problem is that when I click the Yes checkbox on the subform, all of the checkboxes are checked. Currently, I have a field...
0
2603
by: microsoft.public.dotnet.languages.csharp | last post by:
I have a numeric Oracle field which stores -1 for true and 0 for false. I am trying to populate a checkbox in a datagrid. In my SQL statement, I used the Decode function so that when it populates...
2
2051
by: Marty | last post by:
I have a numeric Oracle field which stores -1 for true and 0 for false. I am trying to populate a checkbox in a datagrid. In my SQL statement, I used the Decode function so that when it populates...
0
265
by: Mike P | last post by:
How do I create and populate a checkbox for a bit field in my datagrid on the OnEditCommand of the datagrid in C#? Currently when the page is loaded the field just says 'True' or 'False'. I don't...
1
1208
by: rodchar | last post by:
hey all, is the following even possible? i have a datagrid with checkboxes on each row, when a user clicks on the checkbox i'd like to populate one of the fields in the grid with the current...
19
8928
by: jdub via AccessMonster.com | last post by:
I created a form that lists all the players from a particular squad in my database. I used the Wizard to create the form and populate the form with the results from a sqad query. It works. My...
4
6715
by: Matt | last post by:
I am no JavaScript guru so please bear with me and be as detailed as possible with your response. I thank you in advance. I have an ASP page that contains form elements. I also have an inline...
7
26068
by: ggfota | last post by:
I have problem creating Access (Continuous) Form with indepenent CheckBox for each record. The user should be able to select records that will be processed by VBA based on ChceckBox value. When I...
0
7157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7195
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6873
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7367
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1400
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
644
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.