Solved

decode a URL with excaped characters

Posted on 2014-03-04
6
208 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
  • 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
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…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now