0

I would like to ask you guys for a little help. I wanted to have my textbox in a modal to have the same value in another textbox in another modal window. The problem is I don't know how. I'm new in using modal windows. Hoping that someone can help me.

Illustration:

Modal window1                  Modal Window 2
textbox1                      textbox2

*textbox1.value must be equal to textbox2.value upon typing. so when the modal window 2 comes out it must have already a value which is the value of Modal window1 textbox1.

user3563036
  • 29
  • 1
  • 1
  • 6

1 Answers1

2

Well you can do this:

$('#textbox1').keydown(function(){
   $('#textbox2').val($(this).val());
});

I presume that you have two textboxes with id textbox1 and textbox2.

I've attached keydown handler, which copies the textbox1's value and assigns it to textbox2 as you type.

Amit Joki
  • 58,320
  • 7
  • 77
  • 95
  • This works well, but if only one modal window is visible at a time you could save some processing by having it only copy the value when the second modal window is shown. Still works this way though so +1. – davidethell Apr 28 '14 at 02:48