robert_gsfame Posted April 21, 2010 Share Posted April 21, 2010 I have created a function in which the value has been encoded, how can i decode the value? unescape???or there is another way Quote Link to comment Share on other sites More sharing options...
Mchl Posted April 21, 2010 Share Posted April 21, 2010 If you created encoding function, you should know how to decode it. Just do what encoding function does in reverse (unless it implements some assymetric algorithm, which I doubt). Quote Link to comment Share on other sites More sharing options...
robert_gsfame Posted April 21, 2010 Author Share Posted April 21, 2010 i have this in my html code onclick="test('$test1')" just let say $test1 ==>simple media@#$%^& has been encoded using urlencode so that i will have this Simple+Media%40%21%24%25%5E%26%2A% function test(x){ var test=unescape(x) alert('test') } using unescape will still leave the + sign, and when i use replace to change the sign with space, how come i still find the + sign??? Quote Link to comment Share on other sites More sharing options...
salathe Posted April 21, 2010 Share Posted April 21, 2010 Use the decodeURIComponent function. Quote Link to comment Share on other sites More sharing options...
robert_gsfame Posted April 21, 2010 Author Share Posted April 21, 2010 not working..... the plus + sign is still there replacing the " " Quote Link to comment Share on other sites More sharing options...
robert_gsfame Posted April 21, 2010 Author Share Posted April 21, 2010 i use replace , unescape, decodeURI everything cannot replace the + with space Quote Link to comment Share on other sites More sharing options...
robert_gsfame Posted April 21, 2010 Author Share Posted April 21, 2010 finally!!! var test=unescape(str.replace(/\+/g, " ")); Quote Link to comment Share on other sites More sharing options...
salathe Posted April 21, 2010 Share Posted April 21, 2010 Ahh, I totally misread the posts. Anyway, glad you got it sorted. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.