EasyUI Forum
September 14, 2025, 12:40:38 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: numberbox issues [solved]  (Read 10754 times)
lcsft
Newbie
*
Posts: 7


View Profile
« on: February 24, 2015, 03:08:23 AM »

Hello,

I am trying to get a numberbox tied to a checkbox, when the checkbox is unchecked I want to remove the required: true and disable the numberbox, but I can't get it to work.
Code:
<input type="checkbox" name="type_online" <?php if($type_online) echo 'checked="checked"'?> onchange="handleOnlineInput(this)" />

<input type="text" name="price_online" value="<?php echo $price_online?>" class="easyui-numberbox" data-options="width:'20%', precision:2, min:0, required: true" checked="checked" />

JS function:
function handleOnlineInput(el)
{
var form = jQuery(el).closest('form');
var price_online = jQuery(form).find('input[name="price_online"]:first');
if( jQuery(el).is(':checked') )
jQuery(price_online).numberbox({required: true, disabled: false});
else
jQuery(price_online).numberbox({required: false, disabled: true});
}

The jQuery(price_online).numberbox({required: true, disabled: false}); doesn't "eat" the attributes at all ... any ideas?

Thanks.
« Last Edit: February 24, 2015, 05:59:17 AM by lcsft » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: February 24, 2015, 04:25:59 AM »

Please use the id selector instead.
Code:
<input type="text" id="price_online" name="price_online" value="<?php echo $price_online?>" class="easyui-numberbox" data-options="width:'20%', precision:2, min:0, required: true" checked="checked" />
Code:
var price_online = jQuery('#price_online');
//...
Logged
lcsft
Newbie
*
Posts: 7


View Profile
« Reply #2 on: February 24, 2015, 05:53:23 AM »

That works, thank you, but I can have the same form opened on multiple tabs, so I can't have the same id (and I don't want to use an automatic id generator), so is there any way around this? So far all other components (like grids, etc) worked fine with a jquery object, instead of an id.
Thx.

Edit: solved it,
instead of input[name="price_online"] I search for a .price_online class (so I add an extra class), like:
Code:
<input type="text" name="price_online" value="..."class="easyui-numberbox price_online" data-options="width:'20%', precision:2, min:0, required: true" checked="checked" />

that way it works, thank you again.
« Last Edit: February 24, 2015, 06:00:43 AM by lcsft » 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!