Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

decode a URL with excaped characters

Posted on 2014-03-04
6
Medium Priority
?
229 Views
Last Modified: 2014-03-05
Experts were instrumental in supplying me with a solution. There were some developmental updates to the backend of my ESP, and so I'm returning for help.

Here's my initial post with your solution ==>
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_27985181.html

Here's the page on the web that is functional ==>
http://e.openmoves.com/profiles/preference-center.html

Use the following URL to sample "functionality" ==>
http://e.openmoves.com/profiles/preference-center.html?email=billgates%40hotmail.com

As I note, the page is functional, except the value of my variable (email=@email@) has been changed. I am collecting data from my email service provider (ESP) to complete the input value for "email". The "@" symbol in the address has been replaced with "%40". I need to unescape that to submit the proper information.

I much appreciate your help. If you cannot extract the javascript form the page I provided, I will gladly send it separately.

Thank you,
JB
0
Comment
Question by:joibrooks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 39904829
var a = decodeURIComponent("billgates%40hotmail.com");

alert( a ); // billgates@hotmail.com
0
 
LVL 58

Expert Comment

by:Gary
ID: 39904831
To decode with js use
decodeURIComponent(string)

But I don't see what this has to do with js, this is something you should be doing at the server...
0
 

Author Comment

by:joibrooks
ID: 39906177
@cathal:
our ESP recently changed the way they return their values. in a trouble ticket that i opened to alert them of the problem, they responded:
"In the following URL, the %40 is actually the correct value and is how the internet is supposed to work. It's called URL encoding."

@cathal and @leakim971:
 i found the decodeURIComponent method online, but I'm not certain how to implement it within my existing javascript. this is where i need your help. please.

the follow script is how i am retrieving the data from the url and placing the value into the email input field.

<script language="javascript">
var gup = function( name ) {
    var results = (new RegExp("[\\?&]"+name+"=([^&#]*)")).exec(window.location.href);
    if ( results == null ) {return ""}
    else {return results[1]}
};

window.onload = function() {
    document.getElementById("emailaddress").value = gup("email");
    document.getElementById("emailaddress2").value = gup("email");
}
</script>

Open in new window


i much appreciate your help.
jb
0
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 39906181
<script language="javascript">
var gup = function( name ) {
    var results = (new RegExp("[\\?&]"+name+"=([^&#]*)")).exec(window.location.href);
    if ( results == null ) {return ""}
    else {return results[1]}
};

window.onload = function() {
    document.getElementById("emailaddress").value = decodeURIComponent( gup("email") );
    document.getElementById("emailaddress2").value = decodeURIComponent( gup("email") );
}
</script>

Open in new window

0
 

Author Comment

by:joibrooks
ID: 39906326
@ leakim971
thank you for another job well done.

jb
0
 

Author Closing Comment

by:joibrooks
ID: 39906337
would i love to go back to school to learn javascript? yes. do i have the time? no. your services are priceless and i recommend experts-exchange often.

jb
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

722 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