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).

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.