Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-11-2004, 05:30 AM   PM User | #1
drainpip
New to the CF scene

 
Join Date: Mar 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
drainpip is an unknown quantity at this point
Trying to work within PayPal

A friend of mine offered to pay me to make a site for him, I only know some advanced HTML and very rudimentary Java... I can pretty much understand how a few lines of code works without knowing all the syntax, but that seems to be my bane in this case.

If anyone is familiar with PayPal's forms, hopefully you got to the same frustration level as I have with all the constraints and whatnot. Here's what I'm trying to do...

A customer needs to come into the first page and select a variety of things to go with their order, for now I just have two drop down menus with two choices each. I'm using location.search to pass that information on to the page with the PayPal buy now button thanks to JavaScript Kit's tutorial on how to do such things. But, I don't know how to insert more than one item into the value of the PayPal form (which will then pass the information along to my friend). Here's some code:

Code:
<HTML>
	 
	<HEAD>
		 
<script Language="JavaScript">
<!--
function nextpage() {
window.location.href = "testing2.html?Flavor1.value='"+document.forms.myForm.Flavor1.value+
		"'&Flavor2.value='"+document.forms.myForm.Flavor2.value+"'"

}
//-->
</script>
		 
	</HEAD>
	 
	<BODY>
		
		<form NAME="myForm">
			  
			<p>
			<select NAME="Flavor1">
				<option value="testing">
				testing
				<option value="testing1">
				testing1
			</select>
			 
			<select NAME="Flavor2">
				<option value="testing">
				testing
				<option value="testing1">
				testing1
			</select>
			 
			<input TYPE="BUTTON" onClick="nextpage()" VALUE="Continue">
			</p>
		</form>
		 
	</BODY>
	 
</HTML>
This will take us to the next page... in the head:

Code:
<script Language="JavaScript">
<!--

function getFromSearch() {
	var x = 0
	mySearch = location.search.substr(1).split("&")
	for (x=0;x<=mySearch.length;x++) {
		eval("document.forms.PayPal."+mySearch[x])
		}
	}

//-->
</script>
And I of course call it in the body... then down to the PayPal form. I want to insert all of the information into the value of item_number if at all possible. I'd settle on putting it into os0 if possible. Here's the form:

Code:
			<form name="PayPal" action="https://www.paypal.com/cgi-bin/webscr" method="post"  target="_parent">
				<input type="hidden" name="cmd" value="_xclick">
				<input type="hidden" name="business" value="email@email.com">
				<input type="hidden" name="undefined_quantity" value="1">
				<input type="hidden" name="item_name" value="Custom">
				<input type="hidden" name="item_number" value="INSERT HERE?">
				<input type="hidden" name="amount" value="1.10">
				<input type="hidden" name="return" 
				value="http://www.website.com">
				<input type="hidden" name="no_note" value="1">
				<input type="hidden" name="currency_code" value="USD">
				<input type="hidden" name="lc" value="US">
				<table>
					<tr>
						<td>
							<input type="hidden" name="on0" value="Custom Label 
							Text">Custom Label Text
						</td>
						<td>
							<input type="text" name="os0" 
							maxlength="200">
						</td>
					</tr>
				</table>
				<input type="image" 
				src="https://www.paypal.com/en_US/i/btn/x-click-but23.gif" border="0" 
				name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
			</form>
So is it possible to use location.search to insert all the information after the ? into one value in this page?

Appreciate it,
pip

Last edited by drainpip; 03-11-2004 at 05:33 AM..
drainpip is offline   Reply With Quote
Old 03-11-2004, 06:06 AM   PM User | #2
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
In your first form, you don't need javascript to dynamically append the form data to url. Let the browser do it for you.

<HTML>
<HEAD>
</HEAD>
<BODY>
<form NAME="myForm" action="testing2.html" action="get">
<p>
<select NAME="Flavor1">
<option value="testing">testing</option>
<option value="testing1">testing1</option>
</select>
<select NAME="Flavor2">
<option value="testing">testing</option>
<option value="testing1">testing1</option>
</select>
<input type="submit" value="Continue">
</p>
</form>
</BODY>
</HTML>

and then in testing2.html, use a more extensive parse querystring script like this
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Old 03-11-2004, 10:05 AM   PM User | #3
jbot
Senior Coder

 
Join Date: Feb 2004
Location: Edinburgh
Posts: 1,352
Thanks: 0
Thanked 0 Times in 0 Posts
jbot is an unknown quantity at this point
if your using a form to send sensitive information, don't use the "get" method since this is a security risk. use "post" instead, as this won't be shown in the address bar of the browser and therefore won't also show up in the browser's history, which would potentially make the site much more easily hacked.

jbot is offline   Reply With Quote
Old 03-12-2004, 02:28 AM   PM User | #4
drainpip
New to the CF scene

 
Join Date: Mar 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
drainpip is an unknown quantity at this point
I appreciate the speedy replies. I got the parser to work to alert the information, but I'm afraid I don't know how to get that class to post information into a form... is there a command I don't know or missed?
drainpip is offline   Reply With Quote
Old 03-12-2004, 06:05 AM   PM User | #5
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
If you use this parser

<script type="text/javascript">
var pqs = new ParseQueryString();
</script>

then you can set the desired fields with the corresponding values in the querystring like this:

window.onload=function(){
document.PayPal.item_number.value=pqs.param("correspondingQueryParameterName");
document.PayPal.os0.value=pqs.param("correspondingQueryParameterName");
}
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Old 03-12-2004, 06:07 AM   PM User | #6
drainpip
New to the CF scene

 
Join Date: Mar 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
drainpip is an unknown quantity at this point
perfect, thanks for helping the amatuer!
drainpip is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:50 PM.


Advertisement
Log in to turn off these ads.