Link to home
Start Free TrialLog in
Avatar of dkbailey1
dkbailey1

asked on

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>
Avatar of SmileMagician
SmileMagician

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!
dkbailey1,

Use the function urlEncodedFormat()

Regards
Plucka
ASKER CERTIFIED SOLUTION
Avatar of James Rodgers
James Rodgers
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
glad i could help

thanks for the points