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
Solved

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

Posted on 2006-07-20
4
220 Views
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?

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>
0
Comment
Question by:dkbailey1
  • 2
4 Comments
 
LVL 1

Expert Comment

by:SmileMagician
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...   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
 
LVL 18

Expert Comment

by:Plucka
ID: 17150720
dkbailey1,

Use the function urlEncodedFormat()

Regards
Plucka
0
 
LVL 25

Accepted Solution

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

escape('&string')

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

Expert Comment

by:James Rodgers
ID: 17154305
glad i could help

thanks for the points
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

860 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