Jump to content
  • 0
Sign in to follow this  
joscetre

Passing Paramaters Containing Amperand (&)

Question

I have a list of names which include an ampersand (eg: "Jack & Jill"), which I am using for users to identify themselves as part of their logon. I want to be able to pass the field value as a parameter within a string, but it only passes the part of the field before the ampersand (eg: "Jack"). Is there a way to pass a parameter that contains ampersands within the field values?

Share this post


Link to post
Share on other sites

14 answers to this question

Recommended Posts

  • 0

How about the following, I've tested this one and should work:

<script>
var v_name = "[@field:Mailing_Names]" ;
v_name = v_name.replace(/&/gi,'&');
document.write("[url="http://b6.caspio.com/dp.asp?AppKey=ddae2000c2f0bb5fd8424eba8ca5&Mailing_Names="]link[/url]") ;
</script>

Share this post


Link to post
Share on other sites
  • 0

Very good question. Browsers recognize & as a reserved character (parameter separator) in a query string so if your data includes & you need to encode it. You can use a Java Script to encode the special characters, here is a sample script that you can put into your HTML block where you define your query string.

 <script>

document.write("[url="mysite.com?param="]link[/url]") ;

</script>

Best,

Bahar M.

Share this post


Link to post
Share on other sites
  • 0

Thanks, Bahar. It looks like it should work, but the code you quote does not seem to pass the parameter. Here is my specific version:

<script>
document.write("[url="http://b6.caspio.com/dp.asp?AppKey=ddae2000c2f0bb5fd8424eba8ca5?Mailing_Names="]link[/url]") ;
</script>
I know that [@field:Mailing_Names] contains the correct data. When I right-click on the link to view its properties, it only shows as far as Mailing_Names=, and does not include the value. I'm wondering in the format it not quite correct. Any advice?

Thanks

Trevor.

Share this post


Link to post
Share on other sites
  • 0

Jason & Bahar, thanks for the correction, not sure how I missed that.

But unfortunately it's still not quite right. I'm trying to pass the parameter value "Trevor & Justine Joscelyne". The link does not add the parameter value, but looks like this:

"http://b6.caspio.com/dp.asp?AppKey=ddae2000c2f0bb5fd8424eba8ca5&Mailing_Names="

However, I tried changing the position of the second single quote in the script like this:

<script>
document.write("[url="http://b6.caspio.com/dp.asp?AppKey=ddae2000c2f0bb5fd8424eba8ca5&Mailing_Names="]link[/url]") ;
</script>
Which results in this link, which looks more hopeful:

"http://b6.caspio.com/dp.asp?AppKey=ddae2000c2f0bb5fd8424eba8ca5&Mailing_Names=Trevor%20%26amp%3B%20Justine%20Joscelyne"

But it's still not being recognized by the datapage that's receiving it. Question - is that the way the link should look, or is something else wrong?

Share this post


Link to post
Share on other sites
  • 0

I'm glad you got it to work!

Let me clarify that ? is the start point of parameters in a query string. If you use direct Caspio URL which already has one parameters "appkey" then next parameters should be added using & in the link.

Best,

Bahar M.

Share this post


Link to post
Share on other sites
  • 0

Hello,

I created a small project in which i want to pass value on next page in URL on button click in caspio. value are pass in URl like below

"offer_created.php?id=11"

but I don't know how to access that value from url in next caspio form .

Please sent me solution ASAP.

Share this post


Link to post
Share on other sites
  • 0

You can try this code, executing the parameters with ampersand(&) in values.

<script> 
var v_name = "[@field:yourfieldname]"; 
v_name = v_name.replace(/&amp;/gi,'%26');
v_name = v_name.replace(/&/gi,'%26'); 
document.write('<a href="www.yourwebsiteurl.com?yourfieldname=' + v_name + '">View Details</a>'); 


</script>
 

Share this post


Link to post
Share on other sites
  • 0

Can't seem to get any of the solutions to work. The HTML Block doesn't seem to want to display the  document.write. Perhaps I am not understanding or inserting the script correctly. Any insights are appreciated. Thanks!

 

Share this post


Link to post
Share on other sites
  • 0

document.write is not supported on pages anymore. Instead you need to create a div and write in that div:

 

<div id="myurl"></div>
<script>
var v_name = "[@field:Mailing_Names]" ;
v_name = v_name.replace(/&/gi,'&');
document.getElementById('myurl').innerHTML ="[url="http://b6.caspio.com/dp.asp?AppKey=ddae2000c2f0bb5fd8424eba8ca5&Mailing_Names="]link[/url]";
</script>

 

Share this post


Link to post
Share on other sites
  • 0

Hello,

 

If you want to pass your parameter via query string , you may want to consider a different approach I came up with.

 

In a Tabular Report Record:

1.) Create an HTML Block

2.) Disable the HTML Editor from the Advanced Tab

3.) Paste the code below then replace the variables corresponding to your need.

<a id="link-[@cbRecordIndex]" target="_blank"> [@field:name] </a>

<script>

  var protocol = 'http://';
  var base_url = 'www.google.com';
  var param = 'param';
  var qStringVal = `[@field:name]`;

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

</script>

 

Hope this helps.

Regards,

DN31337

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×