Jump to content

[SOLVED] a little buggy the way i have this set up.. any help?


zang8027

Recommended Posts

http://www.tendertouchtowels.com/pricing/index.php?

 

If you go to that page, you will see a textbox with the default value of "Please enter your quantity here". When you click in the box, it removes it and allows you to type the next value. When you type a value, click out of the box and look at your url change to add ?quan=1251 (or whatever you entered)

 

The reason i have this is because i have a simple php if statement that pulls the parameter "quan" from the url, checks to see if its between 0-1000, 1001-5000, or 5001-10000 +. Now, you can see the problem is that this forces the user to click out of the box in order for it to accept the value.

 

I tried using onkeyup but thats buggy because if you are a slow typer or whatnot, it fires the on key up as soon as you type the first number.

 

Header js functions for clearing text on click and adding param

<script type="text/javascript">
function upperCase(x)
{
var y=document.getElementById(x).value;
self.location='index.php?quan=' + y ;
}
</script>

<script>
function clearText(theField)
{
if (theField.defaultValue == theField.value)
theField.value = '';
}

</script>

 

The form

<!-- Form goes here -->
	<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type='hidden' name='cmd' value='_cart' />
  	<input type="hidden" name="business" value="$email" />
   	<input type="hidden" name="upload" value="1" />
   	<input type="hidden" name="lc" value="US" />
   	<input type="hidden" name="currency_code" value="USD">
   	<input type="hidden" name="item_name_1" value="Tender Touch Towels" />

<?php

  //recieve the passed amount
$amount = $_REQUEST['quan'];

if(isset($_REQUEST['quan'])){
if($amount > 0)
{
   if($amount <= 1000)
   {
   echo '<input type="hidden" name="quantity_1" value="'.$amount.'" />';
   echo '<input type="hidden" name="amount_1" value="0.19">';
   }
}

if($amount >=1001)
{
   if($amount <=5000)
   {
      //post form to paypal with $amount and 0.18
   echo '<input type="hidden" name="quantity_1" value="'.$amount.'" />';
   echo '<input type="hidden" name="amount_1" value="0.18">';
   }

}

if($amount >=5001)
{
   if($amount <=10000)
   {
      //post form to paypal with $amount and 0.17
   echo '<input type="hidden" name="quantity_1" value="'.$amount.'" />';
   echo '<input type="hidden" name="amount_1" value="0.17">';
   }

}

}

?>

	<input id="fname" class="price_box" value="<?php if(isset($_REQUEST['quan'])){$quan=$_GET['quan'];echo "$quan";}else{echo "Type your quantity here...";}?>" onblur="upperCase(this.id)" onfocus="clearText(this)">
	<input type="submit" class="order_button">
	</form>

 

 

Is there a better way to do this?  I tried a php processing page but how can i send these hidden inputs for paypal from a processing page? Wouldn't i need to manually do it via button

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.