Jump to content
  • 0
Sign in to follow this  
TroubleShooter

Passing field values with ampersand (&) over query String

Question

Hello

 

Is it possible to pass a field with special charaters such as ampersand over query string?

I was trying to pass a field value to another webpage but it seems to break after the & character. Is there something we can do to receive this onto the other page.

 

Any help is appreciated.

 

many thanks,

TS

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Hello @TroubleShooter,

 

The reason why the ampersand symbol is being cut is because Caspio renders the link literally. In this example:

<a href="https://www.google.com?myParameter=[@field:someField]"> Link </a>

 

If "someField" evaluates to "Some Value & Another Value" then the mark-up would result to 

<a href="https://www.google.com?myParameter=Some Value & Another Value"> Link </a>

 

This is when urlencoding comes into play. What this does is substitutes the special characters in a standard HTML format which interprets characters a different way.

 

You may try using my code snippet below.

1.) Just replace the link ID with the id attribute of your link.

2.) repeat the addParameter function as needed. The first argument is your parameter name, and the second argument is your field value.

<a href="#" id="link-1">MyLink</a>

<script>
// DO NOT TOUCH FROM THIS POINT
var params = []; 
addParameter = function(qs, val){
  params.push(`${qs}=${encodeURIComponent(val)}`);
}
//UP TO THIS POINT

var link_id = "link-1";
var base_url = "https://SomeDomainFrom.caspio.com/dp/926560as124321324dasd00a6523f123123624543123423fc0453b9093";
addParameter('boo', '[@field:SelectedAction]'); //repeat as needed
addParameter('far', '[@field:SelectedAction]');


  
// DO NOT TOUCH FROM THIS POINT
var queryString = params.join("&");
document.querySelector(`#${link_id}`).href = `${base_url}?${params.join("&")}`
//UP TO THIS POINT


</script>

 

Works for me.

 

-DN31337!

Share this post


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...
Sign in to follow this  

×
×
  • Create New...