473,395 Members | 1,856 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,395 software developers and data experts.

How do i clear textBox contents when checkBox is unchecked

1
Expand|Select|Wrap|Line Numbers
  1. function getCurrentDateString(checkBox, inputName){
  2.     if(checkBox.checked == true){
  3.         var inputBox = eval("document.PortfolioInquiryChange."+inputName);
  4.         if(inputBox.value==""){
  5.             var dateobj= new Date();
  6.              var month = dateobj.getMonth();
  7.              var day = dateobj.getDate();
  8.              var year = dateobj.getFullYear();
  9.             inputBox.value= day + "/" + month + "/" + year;
  10.         }
  11.  
  12.     }
  13.     else{ 
  14.         inputBox.clear();
  15.     }
  16.  
  17. }
Apr 16 '14 #1
1 1476
Dormilich
8,658 Expert Mod 8TB
you simply set the value to an empty string (there is no clear() method on form fields). you may also call the reset() method of the form, although that will reset all form elements.

PS. don’t use eval() on line #3, bracket notation will do.
Apr 16 '14 #2

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

Similar topics

2
by: Jack Black | last post by:
Hi, all!! Trying to clear the contents of a frame (or iframe), and can't seem to find anything that works. Tried: * innerHTML * outerHTML * document.close(); (with a number of different frame...
4
by: Targa | last post by:
I have a form in which I want to have an button(image) displayed next to a checkbox when it is checked. If the box is unchecked, the button should disappear. How can I do this? Thanks!
2
by: RSB | last post by:
I have a data grid and i want to Clear the Contents .. How do i do that.. Is there any direst property ?? thanks RSB
2
by: Javier | last post by:
Hi Everyone, I have a dynamic checkbox in a datagrid that uses the ITemplate interface and has the checkchanged event wired up. When the checkbox is checked, the event event handler that...
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: Dhananjay | last post by:
hi everyone i have a problem how to save the textbox contents to sql server database. i am getting this contents after conversion from web browser into textbox(multiline) I want to store all the...
2
by: g7murali123 | last post by:
hi, my textbox contains text as "search" on pageload when the user click the textbox the text "search" should disappear and the textbox must get the value of the user entering text. please help the...
1
by: patryck aguilar | last post by:
Hi there, I would like to be able to clear the textbox when we uncheck the checkbox. Is that possible? <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
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
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.