Copied to clipboard

Flag this post as spam?

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


  • Andres Tenjo 35 posts 55 karma points
    Mar 27, 2011 @ 19:26
    Andres Tenjo
    0

    java script and xslt and node upted...

    Hi there ! 

    I'm dev this function to add a new vote or count +1 in a node for each selection in js..

     

        <!-- start writing XSLT -->

     

        <xsl:variable name="documentTypeAlias" select="string('Quiz')"/>

        <xsl:variable name="options" select="string('QuizOptions')"/>

     

        <script type="text/javascript">

          ...

          iSend = $("#content input[name=quiz]:checked").val();

          ...

        </script>

     

        <xsl:variable name="tmp">

          <xsl:value-of select="isend"/>

        </xsl:variable>

     

        <xsl:variable name="myvar" select="number($tmp)"/>

     

        <xsl:value-of select="visitTrack:updateVisit($myvar)"/>

     

      </xsl:template>

     

     

      <msxml:script language="C#" implements-prefix="visitTrack">

        <msxml:assembly href="../bin/cms.dll" />

        <msxml:assembly href="../bin/umbraco.dll" />

        <msxml:assembly href="../bin/businesslogic.dll" />

        <msxml:using namespace="umbraco.BusinessLogic" />

        <msxml:using namespace="umbraco.cms.businesslogic.web" />

        <msxml:using namespace="umbraco.cms.businesslogic.web" />

        public static string updateVisit(int myvar)

        {

        User author = User.GetUser(0);

        Document doc = new Document(myvar);

        int getCount=int.Parse(doc.getProperty("numberanswers").Value.ToString()) + 1;

        doc.getProperty("numberanswers").Value = getCount.ToString();

        doc.Publish(author);

        umbraco.library.UpdateDocumentCache(doc.Id);

        return getCount.ToString();

        }

      </msxml:script>

    </xsl:stylesheet>

     

     

    But it present this error: Value was either too large or too small for an Int32. 

    And I not sure that it works completely

    Someone can help me ??? 

    Thanks...

     

     

     

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Mar 27, 2011 @ 21:32
    Chriztian Steinmeier
    0

    Hi Andres,

    There could be several reasons why you're getting that error - but it's probably because the value you're trying to send to the updateVisit() function can not be converted to an Int32...

    Based on the code you've supplied, I'm guessing you're trying to assign the XSLT variable tmp the value of a JavaScript variable (which obviously doesn't exist at the time the XSLT is running) - what's happening in your code is that XSLT is trying to find "isend" as a childnode on the root of the macro XML (I'm guessing the above is inside the template matching "/").

    - Where is the XSLT supposed to take the value for the tmp variable from?

    /Chriztian

  • Andres Tenjo 35 posts 55 karma points
    Mar 27, 2011 @ 22:16
    Andres Tenjo
    0

    yea this xslt have been on the top of the form when this be submitted ...

     

Please Sign in or register to post replies

Write your reply to:

Draft