Chariel Posted October 18, 2021 Share Posted October 18, 2021 Hi everyone! I'm still sperimenting and working on PS. I have created a form with some fields I want to show / hide on with a switch like: array( 'type' => 'switch', 'label' => $this->module->l('Add a message?'), 'is_bool' => true, 'name' => 'message', 'id' => 'message', 'values' => array( array( 'id' => 'message_on', 'value' => 1, 'label' => $this->module->l('Enabled') ), array( 'id' => 'message_off', 'value' => 0, 'label' => $this->module->l('Disabled') ) ), ), array( 'type' => 'text', 'col' => 3, 'class' => 'text-field-width', 'label' => $this->module->l('Text'), 'name' => 'text', 'required' => false, 'lang' => true, ), and I want to show my input named "text" only if my switch is on "on" / enabled. I tried something like $(function() { $("#message").click(function() { if ($(this).is(":checked")) { $('input[name="text"]').parent().parent().show(); } else { $('input[name="text"]').parent().parent().hide(); } }); }); but is not working (the .js file in insiede a .js file that is working, I added other features to the form with js and are perfectly working so it is not a problem of file, relationship with js or others!). Any idea, advice and so on woulb be really appreciated! Thank you! ^^ Link to comment Share on other sites More sharing options...
delete-account-pleas Posted October 18, 2021 Share Posted October 18, 2021 You have no javascript error? With smarty sometimes its better to use document on click: $(document).on("click","#message",function() { alert("click bound to document listening for Element"); }); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now