Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,074
    Thanks
    0
    Thanked 256 Times in 252 Posts
    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
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  • #4
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,074
    Thanks
    0
    Thanked 256 Times in 252 Posts
    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
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #6
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    perfect, thanks for helping the amatuer!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •