Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update the value in one text box based on the value entered in another text box?

How do I update the value in one text box (txtInterest%) based on the value entered/changed in another text box (txtAmt)?

like image 279
OBL Avatar asked Dec 31 '10 00:12

OBL


People also ask

How do I change the value of a textbox after update?

Highlight the textbox called Textbox1. Click on the property called "After Update". A button with 3 dots to the right should appear. Click on this button. When the Choose Builder window appears, highlight Code Builder. Click on the OK button. Now, when a value of 1 is entered in Textbox1, Textbox2 will automatically be populated with a value of 10.

How to set textbox2 based on the value entered in TextBox1?

For example, if someone enters a value of 1 in Textbox1, then I want to set Textbox2 = 10. Answer: To set the value of Textbox2 based on the value entered in Textbox1, you need to place your VBA code on the "After Update" event of Textbox1. To do this, open your form in Design View. Under the View menu, select Properties.

What is the Defaut value for the third textbox?

The defaut value can be anything you like in your third textbox, but, for you example to work you need to set the Text proprety of the third textbox to TxtReveived.Text. For your last TxtRecieved.Text value should be reflected as a.

How to set textbox2 to automatically populate with a value?

When the Choose Builder window appears, highlight Code Builder. Click on the OK button. Now, when a value of 1 is entered in Textbox1, Textbox2 will automatically be populated with a value of 10.


2 Answers

Use jQuery's change method for updating. Using your example:

$('#txtAmt').change(function() {
  //get txtAmt value  
  var txtAmtval = $('#txtAmt').val();
  //change txtInterest% value
  $('#txtInterest%').val(txtAmtval);
});
like image 124
bpruitt-goddard Avatar answered Oct 19 '22 22:10

bpruitt-goddard


This should work assuming txtAmt and txtInterest% are ids on your page:

$(function() {
    $('#txtAmt').change(function() {
       $('#txtInterest%').val(this.value);
    });
});

See jQuery's change event handler.

like image 39
Jacob Relkin Avatar answered Oct 19 '22 23:10

Jacob Relkin