Link to home
Start Free TrialLog in
Avatar of indyng
indyng

asked on

How do I use Server.URLEncode on a string?

Hi Experts,

I have the following:


document.location.href= "AddLoad.asp?RecDate=" + x.RecDate.value + "&DeliveryNo=" + x.DeliveryNo.value + "&ShipmentNo=" + x.ShipmentNo.value + "&ManualNoteNo=" + x.ManualNoteNo.value + "&ReservationNo=" + x.ReservationNo.value + "&ShipFrom=" + x.ShipFrom.value + "&ShipTo=" + x.ShipTo.value + "&FromProv=" + x.FromProv.options[x.FromProv.selectedIndex].value +"&ToProv=" + x.ToProv.options[x.ToProv.selectedIndex].value + "&PayorFreight=" + x.PayorFreight.options[x.PayorFreight.selectedIndex].value + "&TransUsed=" + x.TransUsed.options[x.TransUsed.selectedIndex].value + "&ContainerInitial=" + x.ContainerInitial.value + "&ContainerID=" + x.ContainerID.value +"&Notes=" + x.Notes.value + "&UpdateDetails=1&EditDetails=1"

x.PayorFreight.options[x.PayorFreight.selectedIndex].value  can contain an ampersand sometimes such as "A&B". How can this be handled?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of mshogren
mshogren

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

Server.URLEncode is a bit thick - as mshogren says use JScript's native escape() and unescape() functions

Doh! factor avoidance: Make sure you only escape the values, not the URL &'s!