EasyUI Forum
April 29, 2024, 09:10:41 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: How to set the value of textbox in Dialogue using JS?  (Read 5332 times)
Alfred
Full Member
***
Posts: 134


-Licensed User-


View Profile
« 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.
Logged
Alfred
Full Member
***
Posts: 134


-Licensed User-


View Profile
« Reply #1 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);
            }
        });
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #2 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);
    }
});
Logged
Alfred
Full Member
***
Posts: 134


-Licensed User-


View Profile
« Reply #3 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.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!