How to pass a parameter with an '&' in the string using javascript?

Posted on 2006-07-20
Last Modified: 2013-12-24
I have a Javascript function that executes a webpage using ifrHidden.location.  Sometimes a string with an '&' is being passed into the URL, but it doesn't work with a string like that.  Is there a Javascript function that I can use to deal with this?


<script language="javascript" type="text/javascript">
  function jsTierChange(urlpar){
     if (urlpar == 'secondTier'){
       ifrHidden.location = 'generateSecondTierList.cfm?firstTier=' +   document.workloadrecord.selectProductListFirstTier.value;
      makeHttpRequest('selectList1.html', 'alert');
      ifrHidden.location = 'generateThirdTierList.cfm?secondTier=' + document.workloadrecord.selectProductListSecondTier.value;
     makeHttpRequest('selectList2.html', 'alert');                  
Question by:dkbailey1
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Expert Comment

ID: 17149473
Would replacing the ampersands with the character entity help at all?  & = &amp;    I know i have been able to get around a few errors doing that in the past.

Something you definitely could do is avoid the ampersands all together...

This converts the ?s and &s to just slashes, which is also far more search engine friendly. Cheers!
LVL 18

Expert Comment

ID: 17150720

Use the function urlEncodedFormat()

LVL 25

Accepted Solution

James Rodgers earned 500 total points
ID: 17154257
try using teh js functions escape and unescape


will convert it to hex, same as cf function urlencodedformat
LVL 25

Expert Comment

by:James Rodgers
ID: 17154305
glad i could help

thanks for the points

Featured Post

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question