Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Donate page

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 08-23-2010, 09:22 AM
  ARW VISIONS's Avatar 
ARW VISIONS ARW VISIONS is offline
 

X-Man
  
Join Date: Jan 2007
Location: Pensacola, FL
Posts: 2,536
 

Default Donate page

ver - 4.1.12

Ok so I have a donate page on a site I built.

Right now I just left the price blank so they can enter an amount in.

Is there a way to have a drop down with various amounts AND the empty text box as an other option?
__________________
xcart 5.1.2
Reply With Quote
  #2  
Old 08-23-2010, 02:33 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: Donate page

You can. Just do a check after submit - if textbox empty use the amount from dropdown else use the amount from textbox. Also have to do check textbox allows numbers only. You have to do js client side check but also server side check in case js is turned off in customers browser
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #3  
Old 08-23-2010, 08:28 PM
  ARW VISIONS's Avatar 
ARW VISIONS ARW VISIONS is offline
 

X-Man
  
Join Date: Jan 2007
Location: Pensacola, FL
Posts: 2,536
 

Default Re: Donate page

ok I can do the JS part, but how do I do the server side part?
__________________
xcart 5.1.2
Reply With Quote
  #4  
Old 08-23-2010, 09:10 PM
 
Shamun Shamun is offline
 

X-Adept
  
Join Date: Jun 2009
Location: North Carolina
Posts: 841
 

Default Re: Donate page

Noob at PHP but perhaps something like this?

$var = intval($_POST['formName']);
__________________
- Shane Munroe
Reply With Quote
  #5  
Old 08-23-2010, 09:11 PM
  ARW VISIONS's Avatar 
ARW VISIONS ARW VISIONS is offline
 

X-Man
  
Join Date: Jan 2007
Location: Pensacola, FL
Posts: 2,536
 

Default Re: Donate page

yeah, Im a design guy, so writing PHP to check that might be over my head. I'll check it out.
__________________
xcart 5.1.2
Reply With Quote
  #6  
Old 08-23-2010, 09:18 PM
 
Shamun Shamun is offline
 

X-Adept
  
Join Date: Jun 2009
Location: North Carolina
Posts: 841
 

Default Re: Donate page

Stupid forum submitted my post before I wanted.

What I posted before was simply making sure it was posted as an integar.
For checking which was submitted you could do maybe something like this:
Code:
$var = intval($_POST['formName']); $var2 = intval($_POST['dropdownName']); if($var > 0 && $var2 > 0) { Both have stuff in them. You decide which to use } if($var > 0) { Value was found and is greater than 0 in the form. Do php stuff }; if($var2 > 0) { Value was found and is greater than 0 in the dropdown. Do php stuff };

Again, I'm a noob at php and may be insecure or used too much logic/faulty logic.
__________________
- Shane Munroe
Reply With Quote
  #7  
Old 08-24-2010, 03:17 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: Donate page

Yes you need to do that in the php file responsible for processing the form. Something like
var1 -dropdown
var2 - text field

P.S. same happened to me - forum submitted before I finished

PHP Code:
if (!empty($var2)) {
 
# use text field value
 
if (!is_numeric($var2))
  
$error true;
  
# if field value is not a number throw an error, process it and redirect back to the form for re-submision
 
else
  
# if field value is a number
  
$var2 intval($var2);
 
# do more php stuff
} else {
 
# if text field is empty use dropdown value
 
$var1 intval($var1);
 
# do more php stuff

__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



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
Forum Jump


All times are GMT -8. The time now is 06:03 AM.

   

 
X-Cart forums © 2001-2020