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

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?

Thanks.

<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');
}                  
else{
      ifrHidden.location = 'generateThirdTierList.cfm?secondTier=' + document.workloadrecord.selectProductListSecondTier.value;
     makeHttpRequest('selectList2.html', 'alert');                  
}
}
</script>
dkbailey1Asked:
Who is Participating?
 
James RodgersConnect With a Mentor Web Applications DeveloperCommented:
try using teh js functions escape and unescape

escape('&string')

will convert it to hex, same as cf function urlencodedformat
0
 
SmileMagicianCommented:
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...   http://developer.fusium.com/tools/ses.cfm

This converts the ?s and &s to just slashes, which is also far more search engine friendly. Cheers!
0
 
PluckaCommented:
dkbailey1,

Use the function urlEncodedFormat()

Regards
Plucka
0
 
James RodgersWeb Applications DeveloperCommented:
glad i could help

thanks for the points
0
All Courses

From novice to tech pro — start learning today.