Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • bob baty-barr 1180 posts 1294 karma points MVP
    Feb 23, 2010 @ 21:46
    bob baty-barr
    4

    sharing a client request and solution

    had a client ask me to develop something for them this morning and thought i would share....

    client wanted a little checkbox on a page confirming they agree, then activate a button to take you to an off site appliction... no data storage or anything going on on the umbraco side... i just needed a deactivated button, a checkbox to activate it and a macro to really let the client take care of this because they were not entirely clear on the forwaring url, etc.

    so, here is what i did....

    first, made sure i had jquery on the page...

    then, wrote this little function...

    <script type="text/javascript">
    /* <![CDATA[ */
        function toggleStatus() {
                if ($('#toggleElement').is(':checked')) {
                $('#elementsToOperateOn :input').removeAttr('disabled');
            $('#elementsToOperateOn :input').addClass('pretty-button');
            } else {
            $('#elementsToOperateOn :input').attr('disabled', true);
            $('#elementsToOperateOn :input').removeClass('pretty-button');
            }
    }
    /* ]]> */
    </script>

    made sure i set the form/button to inactive on my document.ready code...

    <script type="text/javascript">
    /* <![CDATA[ */
    $(document).ready(function(){

    $('#elementsToOperateOn :input').attr('disabled', true);

    });
    /* ]]> */
    </script>

    then, i created a simple xslt macro -- allowed it to be inserted into the wysiwyg editor and viola! here is my xslt...

    <xsl:template match="/">
    <xsl:variable name="confirmText" select="/macro/checkBoxText"/>
    <xsl:variable name="buttonText" select="/macro/submitText"/>
    <xsl:variable name="landingPage" select="/macro/landingPage"/>

    <!-- start writing XSLT -->
    <form action="{$landingPage}" method="post">
    <p>
        <input id="toggleElement" type="checkbox" name="toggle" onClick="toggleStatus()" />&nbsp;<xsl:value-of select="$confirmText" disable-output-escaping="yes"/>
    </p>

    <div id="elementsToOperateOn">
    <input type="submit" value="{$buttonText}" id="surveyButton"/>
    </div>
    </form>
    </xsl:template>

    Hope someone finds this useful for a project need up the line somewhere :)

  • Chris Houston 535 posts 980 karma points MVP admin c-trib
    Feb 24, 2010 @ 02:30
    Chris Houston
    1

    Hi Bob,

    A useful post, but not sure it's the right place for it?

    Just a thought, maybe we should create a section of the Wiki for "code snippets" where things like this are collected, as I see the forum is really for questions and answers, but code like this would maybe be easier to find if it had an area on the wiki.

    I am guessing you don't have a blog that you could have posted it onto? ( but even if you did.. getting an area on the our. site for code would be great :) )

    Cheers,

    Chris

  • bob baty-barr 1180 posts 1294 karma points MVP
    Feb 24, 2010 @ 04:25
    bob baty-barr
    1

    yeah, i debated long and hard where to put it... it wasn;t really extending umbraco... it doesn't really fit xslt [but kinda] so i totally dig your idea for adding an area... who do we ask? NH? Dirk? - oh, but wait...you too look to be an admin, my friend! Make it so!   ;)

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Feb 24, 2010 @ 09:27
    Dirk De Grave
    0

    Great snippet, but indeed fits nicer on the wiki... why not create a new area on the Reference section?

     

    Cheers,

    /Dirk

     

  • bob baty-barr 1180 posts 1294 karma points MVP
    Feb 24, 2010 @ 16:36
    bob baty-barr
    1

    okay, i created a new category in the wiki under reference and placed the snippet above in there. Feel free to delete this one or add snipets to the wiki :)

    http://our.umbraco.org/wiki/reference/code-snippets

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies