how to change the value of checkbox when i change the value of textbox

i want the checkbox to change its value to unchecked when the textbox doesnot have anything i.e is value is "" and as soon as i enter anything to it, the checkbox should automatically change to checked. Can you please tell me how to do this

0
needy
6/4/2008 11:34:19 AM
asp.net.client-side 24353 articles. 1 followers. Follow

5 Replies
1104 Views

Similar Articles

[PageSpeed] 15

Add to the textbox:

OnKeyUp="CheckValue()"

Add to the html:

<script language="javaScript">

function CheckValue() {

if (document.getElementById('textboxid').value.length == 0) {

document.getElementById('checkboxid').checked = false;

}

else {

document.getElementById('checkboxid').checked = true;

}

}

 

Nick

0
nick
6/4/2008 1:15:25 PM

nick-w:

Add to the textbox:

OnKeyUp="CheckValue()"

Add to the html:

<script language="javaScript">

function CheckValue() {

if (document.getElementById('textboxid').value.length == 0) {

document.getElementById('checkboxid').checked = false;

}

else {

document.getElementById('checkboxid').checked = true;

}

}

 

Nick

So you're going to check/uncheck the CheckBox on each and every key stroke? Why not just use the onblur event? That way you'd only check/uncheck the CheckBox once, when the TextBox gains the focus and then loses it.

NC...

 

0
NC01
6/4/2008 1:37:01 PM

NC01:

So you're going to check/uncheck the CheckBox on each and every key stroke? Why not just use the onblur event? That way you'd only check/uncheck the CheckBox once, when the TextBox gains the focus and then loses it.

NC...

Because the OP said "as soon as i enter anything to it, "

 

Nick

0
nick
6/4/2008 1:58:58 PM

nick-w:

NC01:

So you're going to check/uncheck the CheckBox on each and every key stroke? Why not just use the onblur event? That way you'd only check/uncheck the CheckBox once, when the TextBox gains the focus and then loses it.

NC...

Because the OP said "as soon as i enter anything to it, "

 

Nick

So, he also doesn't know what the solution is. You should point out how un-productive that is.

NC...

 

0
NC01
6/4/2008 2:11:40 PM

Just wanted to point out that the onkeyup version won't work if the user right-clicks and pastes text into the text box.  The onblur version will.


Chris Williams MCP
Software Consultant
SantiAms Limited
0
Monket
6/4/2008 6:03:54 PM
Reply:

Similar Artilces:

how ontextchanged event in datalist fire and when that textbox value change than another textbox inside datalist value also change
 i have one datalist into which i used maskededit extender for time entry there is three textbox (1) start_time (2) end_time (3) duration so when enter  end_date value than this text box ontextchage event fire and duration will automatically calculate by(end_time - start_time) and display into datalist duration textbox. in datalist there is more than one item.i put some code so just check  <asp:DataList ID="CONTRACT_SERVICE_ITEM" runat="Server" RepeatColumns="1" RepeatDirection="Horizontal"      &nbs...

Accessing values on the server for controls whose values were changed client-side
Let's say that I have two server controls, a label and a textbox: <asp:Label ID="Label1" runat="server" Text="Old value"></asp:Label> <asp:TextBox ID="TextBox1" runat="server" Text="Old value"></asp:TextBox> Then I run some client-side code that changes their values: document.getElementById('Label1').innerHTML = 'New value'; document.getElementById('TextBox1').value = 'New value'; In the browser, they both visually have the value "New value".  Howev...

to change value of Client Side Select html control from database value....
hello forum,  I have a select .. Demo.aspx <select id="DropAccType" name="DropAccType"> <option>Select</option> <option>Saving</option> <option >Current</option> <option>Regular</option> <option>Demat</option> </select> I want to set the value of select by fetching the data from daabase i.e. In my table if I have Value current then when i request the demo.aspx then in select Control the value Current should get selected..... Please help me to sort this out...   Thnx in advance.. Hi-I could be...

Changing a textbox value by changing 2 other textboxes inside of a FormView
Ok...here goes.  I want to be able to dynamically change the value of a textbox by changing the value of 2 other textboxes.  I have 4 textboxes, txt1, txt2, txtDB, and txtTotal.  These are all inside of FormView1 which is inside of UserControl1.ascx which is inside of UserControl1.aspx.   The goal is to have txtTotal read the summation of the 3 other textboxes.  txtDB has a bound value read from a database (why it is in a FormView).  txt1 and txt2 can be changed.  I want though, for the txtTotal textbox to change in real time wit...

Changing textbox.Text value when dropdownlist changes
I figure this should be really simple. Here's what I want to happen: Page loads first time, textbox is blank. User changes dropdownlist to a certain value. Page refreshes and changes textbox.text to dropdownlist.SelectedItem.Value but keeps the value of any other textboxes that might've been changed by the user. I can make this work fine when it's just dynamic (non asp.net generated) text in the page. Thanks. hello, there is the OnSelectedIndexChanged which you should define,in that method you set the value of the textbox as follows: txt1.Text = ddl.SelectedItem.Value; ...

Change value of textbox dependent on value from dropdownlist
How do you achieve this but client-side, to avoid the constant page refresh? (Javascript)   Best, Asaf. You need to use an onChange event on your DropDownList and wire it to a JavaScript function. In the code example below, ddlID and txtID are the control IDs of your DropDownList and TextBox controls. Code: ddlID.Attributes.Add("onChange", "setText('" + ddlID.ClientID + "', '" + txtID.ClientID + "');"); JavaScript: function setText(ddl, txt){   var ddlID = document.getElementById(ddl);   var txtID = document.getElementById(txt);   &...

Changing the value of one cell when the user changes the value of another cell
I am using a standard GridView with multiple columns and a SQLDataSource. One column is called Qty and another column is called Date. When the user clicks the Edit button and enters a quantity into the Qty column, I would like to automatically fill in today's date into the Date column...before the user clicks Save. Any ideas on how to do that? Thanks in advance, Rick     You would have to make an asych call, check out ASP.NET AJAX: http://ajax.asp.net add a javascript event on the quantity textbox the onchange On the gridviews rowdatabound add this  Protected Sub Gr...

Change value into dg textbox but it catches old value
A datagrid is populated by an arraylist.When I'll update: Even changing text, i.e., writing a new text into textbox, the text continue the last one, without changesI turn off viewstate from textbox but nothing yet What is going on? Some help will be appreciated, thanks a lotBest regards,Ivan Andrade Are you dataBinding you datagrid on pageLoad?  If so, wrap if(!IsPostBack) around your databinding.If everything happens for a reason what is the reason for this error?...

change value of label in a gridview based on a checkbox value
I have a gridview with a template column that is bound to a  database field thats a bit datatype.  I was representing it as a checkbox but I want to represent it as a label with a simple Y or N.   I've looked everywhere but nothing seems to be conclusive. Thanks!  Ahh I got it! I found this cool way to set the label to whatever you want depending if its true or not:  <asp:Label ID="lblWaivingCoverage" runat="server" Text='<%# (bool) Eval("WaivingCoverage") ? "Y" : "N" %>'><...

How to update gridview with dropdownbox and textbox values after changing the values
I have papulate the gridview with Dropdownbox(Quantity) and Textbox for price and Product details after updating the quantity and price through javascript, I want to insert into database How can i do help me please<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="100%" CellPadding="4" ForeColor="#333333" GridLines="None" OnRowDataBound="GridView1_RowDataBound" >        <Columns>          &...

change dropdownlist's selected value on textbox change
Hi there, I have one dropdownlist and textbox in template column of gridview. Now whenever grideview is in edit mode user can change textbox and dropdown value. Now I want to set dropdownlist's selected index to 0 when user enter any value in text box using javascript. i m new to javascript. Is there any idea to implement this? Check this out.   var ddl = document.getElementById('<%#dropdownlistname.ClientID%>'); ddl.selectedIndex = 0;    Thanks,santosh_maharajaPlease mark as answer if you got expected solution. this wayprotected void gvw_RowDataBoun...

Changing textbox value back to original value when closing popup
Hi, On my webform, I have 4 textboxes and a submit button. If the user changes the value in the first textbox then submits the form, a popup window appears that has an "Are you sure ..." message, a Yes button, and a No button. If the user presses No, I want to close the popup and return the value of the first textbox back to its original value (before the user changed it). I can get the popup to close; I just can't figure out how to get the first textbox to have its original value. Any ideas? Thanks in advance, Suzanne You could use this javascript: window...

Change value of textbox based on value from dropdownlist using ajax?
Hello, I want to program an aspx form so that depending on what value you select from a dropdownlist, a textbox gets populated using ajax or javasciprt (client based) I did this already server-side by reading from an SQL data table, but it's annoying because of the page refresh, anyway to do the same thing using ajax or javascript? Look at my code below:   Many thanks ! :)   Sub ddllocations_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddllocations.SelectedIndexChanged Dim strconn As String Dim myConnection As New SqlConnection(strconn) ...

textbox value not changed on server side with javascript.
Hello, I've a problem. my textbox value doesn't change on server side when it's modified via javascript.function gf_SetDate(id, newDate){    Calendar.close();    document.getElementById(id).value = newDate;}My control i...

Web resources about - how to change the value of checkbox when i change the value of textbox - asp.net.client-side

Checkbox - Wikipedia, the free encyclopedia
In computing , a checkbox ( check box , tickbox , or tick box ) is a graphical user interface element ( widget ) that permits the user to make ...


XYplorer adds flat select tool, timestamping, sticky checkbox selection and improves portable device ...
... them a date previously copied to the clipboard. sc_* - *.doc matches both files beginning sc_ and those with a .doc extension. Sticky checkbox ...

Beware of checkbox marketing!
... able to sell the product at all and the company will go out of business. (sometimes in those exact words) These are the two edges of the checkbox ...

Disable Lion’s Resume Checkbox When Shutting Down [Video How-To]
One of the most annoying features in OS X Lion for me has been the little checkbox on the shutdown dialog box that states, "Reopen windows when ...

A Checkbox On Your Tax Return Helped Kill Public Campaign Funding
You already hate tax season, and as you move wearily through the cold calculations of the 1040 form, you come across a familiar checkbox. It’s ...

Google's Clever Plan to Replace CAPTCHA With a Checkbox
CAPTCHAs are an unfortunate side effect of the internet. They're those irritating collection of numbers and letters morphed into some Surrealist ...

Great news: New EEOC checkbox category emerges
"Bow-tie'n white boys"? Hey, I tried to anticipate the next expansion in ethnic categorization yesterday with my proposal for recognition of ...

Checkbox Syndrome: Why We Spend Money on Things We Don't Need
Ever been overwhelmed by the temptation to buy the latest shiny thing because it's got another checkbox in the features column? We call this ...

Magid: Google ditching CAPTCHA for 'I'm not a robot' checkbox
We need better security, but we need to find systems that are hard for bad guys to break but easy for good folks to use. Google is one of the ...

Resources last updated: 12/20/2015 7:32:48 AM