Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 757
  • Last Modified:

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
0
indyng
Asked:
indyng
1 Solution
 
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

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now