JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 23rd, 2001, 11:23 AM
Tom Beidler Tom Beidler is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: Santa Barbara, CA, USA
Posts: 11 Tom Beidler User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to Tom Beidler
url encode w/javascript for redirect

I'm integrating a service with iBill, a merchant account service, and running into a problem on Netscape Navigator. I'm loosing variables because the url is not being incoded.

Here's the scenario. When the end user fills out their info at iBill and the transaction is good, iBill forwards them to a web good page that I've created and posted on their servers. My web good page is a redirect to a PHP page on my server which takes the variables passed in the url and dumps them into a database.

I need to url encode the redirect string on the web good page but their servers are not running PHP so I need do it in Javascript...which I'm no good at.

I did find some code at http://www.blooberry.com/indexdot/h...urlencoding.htm but that's directed to a form. I need to customize or rewrite the javascript so it url encodes the string, everytime not onSubmit.

Any help would be appreciated. This job is sooooo close to being done!

Reply With Quote
  #2  
Old August 23rd, 2001, 04:55 PM
Nemi Nemi is offline
Clueless llama
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Feb 2001
Location: Lincoln, NE. USA
Posts: 2,353 Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Days 12 h 39 m 5 sec
Reputation Power: 116
escape is the function you are looking for. Do not escape the whole url. Only escape the VALUE of your variable. example:
PHP Code:
var page "http://www.clanmisfire.com/index.php"
var variable "?variable_name=";
var 
value escape("variable_value");

location page+variable+value;

OR

document.write(page,variable,value); 

Just two of many ways it could be done. Hope that helps.

Reply With Quote
  #3  
Old August 23rd, 2001, 05:58 PM
Tom Beidler Tom Beidler is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: Santa Barbara, CA, USA
Posts: 11 Tom Beidler User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to Tom Beidler
If I had to build a long string could I do it like so;

var*page*=*"http://www.clanmisfire.com/index.php"
var*url_string*=*"?name=";
var*url_string*.=*escape("%%CUSTNAME?");
var*url_string*.=*"?address=";
var*url_string*.=*escape("%%CUSTADDR1?");

%%CUSTNAME? is how I call variables on iBill's server.

Reply With Quote
  #4  
Old August 23rd, 2001, 07:08 PM
Nemi Nemi is offline
Clueless llama
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Feb 2001
Location: Lincoln, NE. USA
Posts: 2,353 Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Days 12 h 39 m 5 sec
Reputation Power: 116
You sure could. I was going to put an example like this:
PHP Code:
var page "http://www.clanmisfire.com/index.php"
var variable "?variable_name=";
var 
value escape("<?= getValue()?>");

location page+variable+value;

OR

document.write(page,variable,value); 

But I didnt want to confuse you if you werent using php. It is the same concept. Repeat as neccessary. Only one thing - when using MORE than one name/value pair, you must offset the subsequent name/value paris using the Ampersand (&). Like so:
PHP Code:
var page "http://www.clanmisfire.com/index.php" 
var url_string "?name="
var 
url_string .= escape("%%CUSTNAME?"); 
var 
url_string .= "&address=";             // <-- notice the ampersand
var url_string .= escape("%%CUSTADDR1?"); 


Just to reiterate, the query string is started with the question mark and uses the ampersand as the delimeter for the variables.
Code:
fully made URL:
www .clanmisfire.com/index.php?prefered_figure=athletic&hair_color=brunette&income=loaded%20with%20money 
/*space in url so page wont pick up as link */

Hope that helps!

Last edited by Nemi : August 23rd, 2001 at 07:10 PM.

Reply With Quote
  #5  
Old August 28th, 2001, 07:47 PM
Tom Beidler Tom Beidler is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: Santa Barbara, CA, USA
Posts: 11 Tom Beidler User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to Tom Beidler
what worked

Thought I would post the code that worked for me.

Here's the scenario. We're using a service called iBill. I posted what's called a web good page, called when the transaction is good, on their server. I needed to pass variables from their server to my php page.

Here's the code;

<html>
<head>
<title>PHP collect page</title>
<script language="JavaScript">
<!--
var page="http://www.myserver.com/relay.php";
var url_string="?trans_id="+escape("%%TRAN?")+"&sub_acct="+escape("%%REF5?")+"&delay="+escape("%%REF4?");
window.location=page+url_string;
//-->
</script>
</head>

Hope it helps someone.

Tom

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > url encode w/javascript for redirect

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap