Jquery: Mirror one text input to another

后端 未结 5 1439
傲寒
傲寒 2020-12-09 04:45

I\'m wanting to have one text field autopopulate with whatever the other text field has being typed into it.

How do I go about this?

Thank you! Hudson

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-09 05:19

    $( document ).ready(function() {
    
        console.log( "ready!" );
    
       /*  $( ".checking" ).blur(function() {
              alert( "Handler for .blur() called." );
            }); */
            $(".formula_open").click(function(){
                getval();
             function getval(){
            var schedulenameexpression= $('.idfield1').val();
            var res = schedulenameexpression.split(/[\s()+*-/]+/);
            var i,text,substri,newitem;
    
            for (i = 0; i < res.length; i++) {
                text = res[i];
               substri = text.substr(6);
                var name ="schid_"+substri;
                var schname = $('#'+substri).val();
                console.log( schname );
                schedulenameexpression = schedulenameexpression.replace("schid_"+substri, $("#"+substri).val());
            }
             $('.idfield2').val(schedulenameexpression);
            }
    
        $('.idfield1').bind('keypress keyup blur propertychange', function() {
            getval();
    
    });
    });
    });
    

提交回复
热议问题