PDA

View Full Version : Referencing a input value in another input box



parkermc
Apr 10th, 2007, 07:35 PM
Hi all. I'm new to this forum and Javascript too. Please excuse me if my actions are out of the ordinary as I have searched for the best forum to join and well....I'm here. ;-)

Here's my question(s)....

Is there a way to take the input from one "input box" and reflect it's value in another "input box"? After all the reading I have done, it's seems this can be accomplished, but I need someway to specify which input box's value goes to a certain place (or another input box).

I know this might be getting a bit confusing by now, but I'm trying to explain the best I can at the moment. Oh, another way I could probably explain this is think of an Excel sheet. For example, cell A1 will be an input box......cell A2 is another input box....cell A3 is another.....and cell B1 is a input/text box and B2 the same.

What is typed in A1 will be reflected in B1. What is typed in A2 and A3 will be calculated and reflected in B2.

Any suggestions? And, please let me know if this is still too confusing. Thank you very much in advance.

parkermc
Apr 11th, 2007, 03:52 AM
Well....after a few hours of knocking my head against the computer, I finally worked it out. Here's what the one simple line was.....

function process1() {
document.getElementById("B1").value = (document.getElementById("A1").value);
}

<input id="A1" name="A1" type="text" value="">

<input id="B1" name="B1" type="text" value="" onFocus="process1()">


Now, my only questions are how to get the values of A2 and A3 so I can calculate these to give the product in B2. I feel like I'm on to something here and don't think this will be too much of a problem. I just wanted to post this code for others.

For the gurus out there, please post better ways to overcome my issues here and correct me where I wrong. I'm always willing to learn better ways. ;-)

bcmoney
Feb 19th, 2009, 09:49 PM
Just got onto this link randomly... was debating the best way to sync up searches from Amazon and eBay using their APIs, and I came up with using this to auto-fill the search boxes:


<script>
function process1() {
document.getElementById("B1").value = (document.getElementById("A1").value);
}
</script>
<input id="A1" name="A1" type="text" value="" onkeyup="process1()">

<input id="B1" name="B1" type="text" value="" onFocus="process1()">


Hope its helpful to somebody!

See it in action here:
http://bcmoney.tv (http://bcmoney-mobiletv.com/pages/comparison.html)