473,406 Members | 2,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Clear the value if unchecked the checkbox

vyon13
8
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 2821
acoder
16,027 Expert Mod 8TB
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
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...
4
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...
7
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...
3
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...
0
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...
6
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...
0
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...
6
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...
10
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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
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...
0
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
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...

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.