Solved

decode a URL with excaped characters

Posted on 2014-03-04
6
224 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
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 
LVL 82

Accepted Solution

by:
leakim971 earned 500 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

623 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