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
LVL 1
indyngAsked:
Who is Participating?
 
mshogrenCommented:
Use

escape(x.PayorFreight.options[x.PayorFreight.selectedIndex].value)
0
 
MrHorizontalCommented:
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!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.