473,804 Members | 4,311 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Clear the value if unchecked the checkbox

vyon13
8 New Member
this is the code that i have copy:i tried to add new function on it,... the function is if the checkbox is unchecked the value inputed by the user will be clear... how to do that..

thanks in advance!!!


Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">
  3.  
  4. <html>
  5.  
  6. <head>
  7. <title></title>
  8. <script language="JavaScript" type="text/javascript">
  9. <!--
  10. // by Vic Phillips http://www.vicsjavascripts.org.uk/
  11.  
  12. function Disable(obj,state){
  13.     clds=obj.parentNode.childNodes;
  14.     if (!obj.ary){
  15.     obj.ary=new Array();
  16.         for (i1=0;i1<clds.length;i1++){
  17.             if (clds[i1].tagName=='INPUT'){
  18.                 obj.ary[obj.ary.length]=clds[i1];
  19.                 }
  20.         }
  21.     }
  22.     for (i=0;i<obj.ary.length;i++){
  23.         obj.ary[i].removeAttribute('disabled');
  24.     }
  25.     if (obj.checked==state){
  26.         for (i1=0;i1<obj.ary.length;i1++){
  27.             obj.ary[i1].setAttribute('disabled','disabled');
  28.         }
  29.     }
  30.     obj.removeAttribute('disabled');
  31.  
  32. }
  33.  
  34. //-->
  35. </script>
  36.  
  37. </head>
  38.  
  39. <body>
  40. <span>
  41. <input type="checkbox" name="" onclick="Disable(this,false);" >
  42. <input type="text" name="" disabled="disabled" >
  43. <input type="text" name="" disabled="disabled" >
  44. <input type="text" name="" disabled="disabled" >
  45. </span><br />
  46.  
  47.  
  48. </body>
  49.  
  50. </html>
Apr 5 '08 #1
1 2841
acoder
16,027 Recognized Expert Moderator MVP
Expand|Select|Wrap|Line Numbers
  1. //To clear a textbox
  2. textbox.value = ""; // where textbox is a reference to the textbox
  3. To check if checkbox is unchecked
  4. if (!obj.checked) { ...
Apr 5 '08 #2

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

Similar topics

2
4607
by: Jerome | last post by:
Hi, I've got the following problem: I'm retrieving data from an SQL Server database. And I want my form to display a checked box in the state corresponding to the value saved in the DB. But somehow that doesn't work!? SQL tells me the value is 1. My ASP page tells me it's 'True'??
4
4632
by: Jack | last post by:
Hi, I have a checkbox the value which goes to a database via a asp page that builds the sql string. In the front end asp page, the checkbox code is written as follows: <i><input type="checkbox" name="chk_Complete" value="<%Response.Write l_IsChecked%>"<%if cbool(l_IsChecked) then Response.Write " checked"%>> The code to captures the checkbox value in the asp page that builds the sql string is follows
7
2945
by: Don | last post by:
Via JavaScript within the client page containing the checkbox, I'm trying to capture the value of a checkbox to make a cookie out of it. But, all I get is the defined "ON" value, even when it is unchecked. I'm using the following construct: document.cookie = "cpceRememberLoginCookie="+document.getPage1.rememberLogin.value+"; expires=Thr, 01-Jan-2015 00:00:00 GMT"; The actual checkbox value passed in the <form> POST reflects the actual...
3
4443
by: newjazzharmony | last post by:
Hello group, I want to automatically select a specific checkbox when a user clicks (selects) a specific item in a radiobutton group. Both controls are in the same form. Let's say for argument's sake that the form looks like this (inessential items left out for the sake of clarity): <form name=form1>
0
3299
by: Jayender | last post by:
Hi , I have placed checkbox in my gridview .. now when i check the chekbox and click anybutton the checkbox becomes unchecked. but when i normally add checkbox in the page it doesnt happen but it happens when i add it to the gridview. why is that ? i have added checkbox like this in my gridview: .......
6
4357
by: Daz | last post by:
Hi everyone. Firstly, I apologise if this i not what you would call a PHP problem. I get quite confused as to what lives in which realm, so if this shouldn't be posted here, please suggest where I should post it. I have created a form, which consists of a list of items, each with a checkbox. When a checkbox is checked or unchecked, the page should be refreshed. During the refresh, the data is validated and the MySQL database is...
0
1432
by: J | last post by:
I'm dynamically adding checkboxes in the Page_Load (regardless of PostBack). When IsPostBack, the checkboxes display as I expected and their checked/unchecked status is also as expected. At this point, I want to find particular checkboxes and determine whether they are check/unchecked, but the code only returns that all the checkboxes are unchecked. void SaveModel(Control parent) { // spin through controls recursively foreach (Control...
6
3541
by: gurge | last post by:
Hello! I have a form in datasheet view with checkboxes. One of them is called Cancelled. In the SQL table it is a bit value. When a user keys in a line, the checkbox should be default unchecked unless he/she checks it. So what I have done is to set the default value to False (have tried 0 as well) and in the bottom row (the add new line row) this box is shown to be unchecked. But once I key in any data in the row, the checkbox...
10
7436
by: k3pp0 | last post by:
Hello. Here's my example form: <form method="get" action=""> <p> <input type="radio" name="radio_example" id="radio1" value="radio1_val" /> <label for="radio1">radio button one</label> </p>
0
9710
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9589
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10593
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10085
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7626
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6858
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3830
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3000
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.