⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

enable field acording select



carlinchisart
  • profile picture
  • Member

Posted 24 March 2012 - 16:17 PM

Hi all,

I don't know if this topic was talked in the forum, but i have the next problem, in the add form of my table i have a tinyint field, grocery transform this in a radiobutton field, is perfect so i need this: when the user select active in radio button, two field are anable in the form, the field in this moment are show ok, but i need when thw user select active this field change to enalbe, when de user select unactive the field are disabled.

so this solution is using javascript, i can write the function in the view? or any file? y see this post

/topic/234-setting-dropdown-selected-index/

but i think this solution is for al forms of grocery, i need this only for one.

thanks.

KaBaDaBrA
  • profile picture
  • Member

Posted 24 March 2012 - 21:08 PM

In the view file you can use jQuery - here is a quick example:


$(document).ready(function(){
$('input[name="deleted"]').click(function() {
if ($(this).val() == '1')
alert('You have selected active');
//do show/hide of items here
else
alert('You have selected inactive');
//do show/hide of items here
});
});


In the code above, when you click the radio buttons generated from the tinyint, it will alert "1" or "0". Try it out - remember to change the input radio name variable to your own. :)

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 24 March 2012 - 21:37 PM

Yeap [member='KaBaDaBrA'] is right.

And if you want to be even more specific (for example only in edit form) you can use the getState method. You can see an example at: http://www.grocerycrud.com/documentation/options_functions/getState

carlinchisart
  • profile picture
  • Member

Posted 24 March 2012 - 22:11 PM

you are masters!!!! thank all, more more thanks!!

is a stupid question, but i don't know how i doed this.

thanks

ALM
  • profile picture
  • Member

Posted 30 September 2012 - 09:17 AM

[quote name='KaBaDaBrA' timestamp='1332623320' post='904']
In the view file you can use jQuery - here is a quick example:


$(document).ready(function(){
$('input[name="deleted"]').click(function() {
if ($(this).val() == '1')
alert('You have selected active');
//do show/hide of items here
else
alert('You have selected inactive');
//do show/hide of items here
});
});


In the code above, when you click the radio buttons generated from the tinyint, it will alert "1" or "0". Try it out - remember to change the input radio name variable to your own. :)
[/quote]

Is it possible to have a complete example with jquery ?
Thanks for your help

ALM
  • profile picture
  • Member

Posted 08 October 2012 - 09:35 AM

Up ! Somebody could help me with [color=#282828][font=helvetica, arial, sans-serif]a complete example with jquery ?[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]Thanks[/font][/color]