Jump to content
  • 0

Passing Paramaters Containing Amperand (&)


Go to solution Solved by bahar_vm,

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?

Link to post
Share on other sites

14 answers to this question

Recommended Posts

  • 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.

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.

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?

Link to post
Share on other sites
  • 0
  • Solution

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>
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.

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>
 

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>

 

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

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...