EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Alfred on October 27, 2016, 09:30:25 AM



Title: How to set the value of textbox in Dialogue using JS?
Post by: Alfred on October 27, 2016, 09:30:25 AM
   
Code:
var q = $('#qnty');
    var t = $('#pSize');
    t.textbox('textbox').bind('change keyup blur keydown', function(e){
         q.textbox('setValue', $(this).val());
});

I am trying to set the value in pSize to qnty using the above but it does not yield any result nor error. My form is in the dialogue. Is it a bug or is there something missing in the code? Your help is greatly appreciated.


Title: Re: How to set the value of textbox in Dialogue using JS?
Post by: Alfred on October 27, 2016, 10:13:06 AM
I just found the answer. I don't know whether it is the right way to do.

Code:
$('#pSize').textbox({
            onChange: function(){               
                var qnt = parseFloat($(this).textbox('getValue'));               
                $('#qnty').textbox('setValue', qnt);
            }
        });


Title: Re: How to set the value of textbox in Dialogue using JS?
Post by: stworthy on October 27, 2016, 06:31:33 PM
The 'onChange' function takes the changed value, you can simply your code as:
Code:
$('#pSize').textbox({
    onChange: function(value){               
        $('#qnty').textbox('setValue', value);
    }
});


Title: Re: How to set the value of textbox in Dialogue using JS?
Post by: Alfred on October 28, 2016, 08:14:46 AM
Thanks sir. My initial problem is in setting the new value in an input form in a dialogue. I have seen your other post here in the forum and I did tried them. But when it comes to a form in a dialogue, it does not work. But when I enclose it using anonymous:

Code:
$(function(){ 
//the code
});

it works.