+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Can I override showState() on the events module

Can I override showState() on the events module

2 posts, 0 answered
  1. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    03 Oct 2010
    Link to this post
    Hi,

    On the events module there is a javascript function attached to the Country dropdownlist, which if "United States" is selected shows the State dropdownlist. I'm in the UK so this isnt actually that helpful..;-)

    What I would simply like to do is to change the javascript function showState so that if United Kingdom is shown it shows the list of states (which I will change to UK counties). This should be a piece of cake, but I just dont know where to find the function showState, it will i'm sure be in an embedded resource??

    Thanks
    higgsy
  2. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    03 Oct 2010
    Link to this post
    Hi,

    I'll answer this one myself as i quickly found an easy solution.

    At the bottom of the file EventsItemNew.ascx and EventsItemEdit.ascx (which i mapped the external templates for), i added this function at the very bottom of the file:

    <script type="text/javascript">
        //<![CDATA[
        function showState() {
            var country = document.getElementById('ctl00_ContentPlaceHolder1_contolPanel_ctl00_ctl01_ctl00_ctl00_ctl00_ctl00_MetaFields_ctl00_Country');
            var state = document.getElementById('ctl00_ContentPlaceHolder1_contolPanel_ctl00_ctl01_ctl00_ctl00_ctl00_ctl00_MetaFields_ctl00_liState');
     
            if (country && state) {
                if (country.value == '' || country.value == 'UNITED KINGDOM') {
                    state.style.display = 'block';
                } else {
                    state.style.display = 'none';
                }
     
            }
        }
     
        if (window.attachEvent) {
            window.attachEvent('onload', showState);
        } else if (window.addEventListener) {
            window.addEventListener('load', showState, false);
        } else {
            window.onload = showState;
        }
        //]]>
    </script>

    As it is the last part of the control to load, it will override the showState function shipped with Sitefinity.

    Hope this helps someone else.
    higgsy
2 posts, 0 answered