Jump to content
  • 0

Passing parameters containing an ampersand


Question

I am trying to solve an issue with a parameter with an ampersand in the value being passed to a url.  I did some research on this forum and found an answer that gets me closer, but still doesn't quite work.  

<a id="link-[@cbRecordIndex]" target="_blank"> Worksheet </a>

<script>

  var protocol = 'http://';
  var base_url = 'xxxxxxx.caspio.com/dp/d86e500027f87dfc582049xxxxxx';
  var param = 'Opportunity_Name';
  var qStringVal = `[@field:Opportunity_Name]`;

  document.querySelector('#link-[@cbRecordIndex]').href = `${protocol + base_url}/?${param}=${encodeURIComponent(qStringVal)}`;

</script>

The parameter [@field:Opportunity_Name] is "Munis & EnerGov".  The resulting url from the code above is :https://xxxxxxxx.caspio.com/dp/d86e500027f87dfc582049xxxxxx/?Opportunity_Name=Munis%20%26amp%3B%20Energov"  and the parameter that is received to the other datapage is "Munis &amp; EnerGov".  So, the & is coming in, which is great, but how do I get rid of the "amp;"?

Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Hello @Empowering,

 

It might be because your field [@field:Opportunity_Name] contains a literal &amp; value. This usually happens when you submit on a Rich Tex Editor.

 Try checking your DataSheet if this is the case. If it is, you may need to run the function over to some HTML Entity decoder like this one [link].


You may also try checking this solution. Which, I think, the output will be the same. If it is, then it is likely that my assumption above is true.

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...