Jump to content

Passing field values with ampersand or # sign over query string


Recommended Posts

I am passing field values to an html datapage hosted on my website to create an invoice.  Anytime there was a "#" included in an address, it would stop all the information following that point.  I have incorporated the code from above and it does pass it on, but now I am getting "%20" anywhere there should be a space and "%23" where the # is included.   Below is my code that I created from the examples on another help forum here.  Do you see where I am creating this problem?  I'm hoping it's something obvious!

<a href="#" id="link-1">VIEW INVOICE</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://janetrippe.com/invoice.html";
addParameter('fn', '[@field:FirstName]'); 
addParameter('ln', '[@field:LastName]');
addParameter('frn', '[@field:FarmRanchName]');
addParameter('ad1', '[@field:MailingAddress]');
addParameter('City', '[@field:City]');
addParameter('State', '[@field:State]');
addParameter('Zip', '[@field:Zip]');
addParameter('Phone1', '[@field:Phone1]');
addParameter('Phone1C', '[@field:Phone1Contact]');
addParameter('Phone2', '[@field:Phone2]');
addParameter('Phone2C', '[@field:Phone2Contact]');
addParameter('DA', '[@field:DeliveryAddress]');
addParameter('DC', '[@field:DeliveryDateComments]');
addParameter('DD', '[@field:BullDeliveryDate]');
addParameter('AAA', '[@field:AAAMemberCode]');
addParameter('Bid', '[@field:BuyerID]');
addParameter('TN', '[@field:TransferName]');
addParameter('Code', '[@field:AIMSid#]');

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

</script>

Here is a sample of what it is pulling; I have a # sign in the address as '4800 #1 Black Horse Pike'; it actually changed the # sign to %23 and the spaces to %20

Thanks so much for your help!!

image.png.f58de0ab336b48d7d98d9f009aff0779.png

Link to comment
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
Reply to this topic...

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