Copied to clipboard

Flag this post as spam?

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


  • Carlos 338 posts 472 karma points
    Feb 07, 2012 @ 22:43
    Carlos
    0

    Razor Parameters combined with Javascript

    How would one go about combining Razor parameters with Javascript?

    I am using Wufoo Forms and I need to fill in some parameters by the author to render the form from my Macro.

    I have indicated where my Razor Parameter needs to go indicated by "RazorParamHere".

    I tried it by adding the value of my var to the JS but it outputted an error on the frontend. Saved fine in the scripting editor in Umbraco. Any ideas??? Thanks

    @{
    var wufooFormHash @Parameter.formHash;
    var wufooFormHeight @Parameter.formHeight;
      
      <script type="text/javascript">var host (("https:" == document.location.protocol"https://secure." "http://");document.write(unescape("%3Cscript src='" host "wufoo.com/scripts/embed/form.js' type='text/javascript'%3E%3C/script%3E"));</script>
      <script type="text/javascript">
      var RazorParamHere new WufooForm();
    RazorParamHere.initialize({
    'userName':'myUserName'
    'formHash':'RazorParamHere '
    'autoResize':true,
    'height':'RazorParamHere',
    'header':'show'
    'ssl':true});
    RazorParamHere.display();
      
    //@wufooFormHash
    //@wufooFormHeight
      
    </script>
      
    }
  • Carlos 338 posts 472 karma points
    Feb 07, 2012 @ 22:49
    Carlos
    0

    Additional. I widdled it down to the .initialize and the .display(); that are having issues with my @wufooFormHash.  I can add them to the 'var' in the Javascript and the string parameters in the Javascript but not on the functions.

  • Rodion Novoselov 694 posts 859 karma points
    Feb 08, 2012 @ 06:36
    Rodion Novoselov
    0

    Hi. The <script> element from the razor point of view is nothing different from any other html element. So, you can treat it the same way.

    For example:

    @{
      var wufooFormHash = Parameter.formHash;
      var wufooFormHeight = Parameter.formHeight;
    }

    <script type="text/javascript">
      //<![CDATA[
      var wufooFormHash = '@wufooFormHash';
      var wufooFormHeight = @wufooFormHeight;
      alert(wufooFormHash);
      alert(wufooFormHeight);
      //]]>
    </script>

     

Please Sign in or register to post replies

Write your reply to:

Draft