Solved

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

Posted on 2006-07-20
4
212 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
Comment Utility
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
Comment Utility
dkbailey1,

Use the function urlEncodedFormat()

Regards
Plucka
0
 
LVL 25

Accepted Solution

by:
James Rodgers earned 500 total points
Comment Utility
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
Comment Utility
glad i could help

thanks for the points
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

771 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now