Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing & in the url

Status
Not open for further replies.

jl8789

MIS
May 22, 2003
293
US
OK, so I am passing a value let's say AT&T in a url parameter of code. So the url would look something like .html?code=AT&T once the javascript deciphers the string value. Trouble is, on the next page it appears the value is AT. This is because up in the url the &T is being treated as the next url variable. How do I get around this?

THANKS!
 
Check out the escape method or the encodeURI method.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
How would I do it in this function?

function submitThisForm(obj){
var radioButtonValue;
radioButtonValue = '';
for (var i=0; i<obj.ParentBillName.length; i++)
{
if (obj.ParentBillName.checked)
{
radioButtonValue = obj.ParentBillName.value;
break;
}
}

if (radioButtonValue == ''){
alert("Please select a Parent Bill Name.");
return false;
}
// Open Preview List
<cfoutput>window.location='dsp_PreviewList.cfm?#cgi.query_string#&LumpSum=true&ParentBillName='+#UrlEncodedFormat(radioButtonValue)#</cfoutput>

THis gives me error resolving parameter, radioButtonValue
 
I also tried this:

var urlString = encodeURI(radioButtonValue);
// Open Preview List
<cfoutput>window.location='dsp_PreviewList.cfm?#cgi.query_string#&LumpSum=true&ParentBillName='+urlString</cfoutput>
 
Hi,
Try:

amper = "<%=Server.UrlEncode("&") %>"
<cfoutput>window.location='dsp_PreviewList.cfm?#cgi.query_string#&LumpSum=true' + amper + 'ParentBillName='+urlString</cfoutput>


[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
No, the screen doesn't even display the page when that code is in the javascript. Thanks though.
 
jl879,

U can not use urlencodedformat the way you are using coz, this way you are trying to run javascript first and then cf, whereas it is the otherway round it works.

So try removing urlencodedformat function, instead, in the javascript function, try doing some sort of "replace" on the radiovalue; replace "&" with your own special character, and then on the target page again do a replace (this time in coldfusion) on the url parameter "parentBillName". to put back the ampersand.

Makes sense?

regards,
Brian
 
Yes, makes sense for a decent workaround. Not sure if I've done a replace in javascript before, but I should be able to handle it on the cf side. Have any quick snippet on how to do a replace in javascript for me? Thanks.
 
function doReplace(formField) {
var objRe = /[&]/
var newVal = formField.value.replace( objRe, '***' );

formField.value=newVal;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top