2

Magento Javascript Question

Does anyone know how I can call the session singleton in Javascript? I have a validation to a form like this which, everytime it validates the checkbox element, I want to to update a value in the session model.

Validation.add(
    'validate-tax', 'This is only applicable to certain states.', function(v) {
        var dropDown = document.getElementById("billing:region_id").querySelector('option:checked').text;
        if ((dropDown != 'New York' && document.getElementById("billing:tax_exempt").checked == false) || (dropDown == 'New York')) {
            Mage::getSingleton('core/session')->setYourNameSession($session_value);
            return true;
        }
    }
);

But I don't know if this is possible.

Additional Information I want to do a server-side validation on a checkbox. To do this my plan is to see if the value in the session is true or false. Alternatively, I was thinking to check the HTML elements directly from an observer, but I do not know how to do it.

cleong
  • 220
  • 1
  • 9
  • Specified this is for magento, whoever marked this is a duplicate, please check to see that the question was not about general differences between client and server – cleong May 25 '15 at 14:57
  • You can make an ajax call to the server, possibly to a module route with a controller that sets your session variable. But you already know this. –  May 25 '15 at 16:20
  • if anyone is interested in knowing, i got the answer. got the variable from the post variable in the frontcontroller – cleong May 25 '15 at 16:35

0 Answers0