0

I have two text boxes and I want them both to submit the same data, such as if the user changes one text box, the other changes to the same value and vise versa.

I am easily able to make one textbox update the second with javascript, but not the other way around (it either won't do it, or neither textbox will accept a value).

I tried two different js functions, tried two different if statements in one function.

I'm using onkeyup (vs. onchange), though I don't know if that's important or not.

It's best not to ask WHY I want to do this, because my explanation will be dumb. Honestly it's to save from having to do an extra IF statement in PHP (and because it looks cool for the enduser).

1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by petrakid
0

Actually, figured it out; pretty straight forward to say the least:

<script type="text/javascript">
          function updateMWM1() {
               document.getElementById('mwm1').value = document.getElementById('mwm2').value;
          }
          </script>
          <script type="text/javascript">
          function updateMWM2() {
               document.getElementById('mwm2').value = document.getElementById('mwm1').value;
          }
          </script>

if there's a better way though please let me know.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.