Wolfzmus Wolfzmus - 9 months ago 62
HTML Question

Duplicate text from another form in real time

Okay probbaly my question is very common, and so many aks this question and answer this. But i have (kinda) have another problem. Usually is work if i text it into vendor, text cgame will follow what i text on vendor (keyup on real time), and i can change it on cgname (not affect to text vendor). But this is my problem, when cgname is empty or i erase text i wanna instaly text cgname into text vendor i mean duplicat text vendor to cgname if text cgname is erase or empty. How do i did that?
this my code on jquery

var cgname = $("#cgname");
$("#vendor").keyup(function() {
cgname.val( this.value );

I'm really2 sorry if u dont understand me what i said, my english really2 worst.

So many people miss understanding my questio. So i'm gonna cleary.
1. I need duplictae text vendor into text cgname
2. If text cganme get erease or empty, go to point 1.

Answer Source

Based on AHJeebon's answer I think you are looking for this :

$("#vendor").keyup(function() {
  $("#cgname").val( $(this).val());

$("#cgname").keyup(function() {
  var val = $(this).val();

  if(!val || val.length === 0 )
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

CG Name <input id='cgname' type='text'>
Vendor  <input id='vendor' type='text'>