• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: can't get IFstatement to work right in script

can't get IFstatement to work right in script 17 years 3 months ago #1645

  • ulnpiper
  • ulnpiper's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
For some reason I can't get this to set the right values.

I have a form where you can buy a number of extra concert tickets and a T-Shirt. Concert tickets are $15 times the number you want.

The tshirt field has the values of either No, Small, Medium...2XL. If you don't select anything, I want the tshirtamt set to 0 (this is the default for the field). If you select a t-shirt size, then it adds $15 to your total.

No matter what I do, it always takes the 'if' statement and sets tshirtamt to 15. Looking in the database, the tshirt field is set to \"No\".

The concert ticket section works fine.

What am I doing wrong?
if($_POST['form']['tshirt'] != \"No\"«»){
  $_POST['form']['tshirtamt'] = 15;
}
 
if(isset($_POST['form']['total'])){
$_POST['form']['total'] = ($_POST['form']['concertticket'] * 15)  +$_POST['form']['tshirtamt'];
}
The administrator has disabled public write access.

Re:can't get IFstatement to work right in script 17 years 3 months ago #1673

  • alex
  • alex's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 443
  • Thank you received: 3
Hi,

this script should be added in the Scripts called on display. I would suggest you to make it run only when the $_POST variable isset, because the form process scritps are run also when the form is displayed. So this is how it should look like:
if(isset($_POST['form']['tshirt'])){
    if($_POST['form']['tshirt'] != \"No\"«»){
         $_POST['form']['tshirtamt'] = 15;
    }else{
         $_POST['form']['tshirtamt'] = 0;
    }
 
    if(isset($_POST['form']['total'])){
        $_POST['form']['total'] = ($_POST['form']['concertticket'] * 15)  + $_POST['form']['tshirtamt'];
    }
}

Let me know if that worked.
The administrator has disabled public write access.

Re:can't get IFstatement to work right in script 17 years 3 months ago #1711

  • ulnpiper
  • ulnpiper's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
Ok, its not the 'if' statement, it has something to do with the tshirt field definition. If I make it a Radio button field, it works...if I make it a select dropdown box, it doesnt work.

The attached image is of the radio field definition...if I change the field type to 'select' it quits working.

I can use a radio button field for now...but is there a way to format them so the buttons line up?

Attachments:
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!