if statement based on state of drop down menu?

How to conditionally query a database based on a dropdown menu selection.

Overview

The issue is not knowing how to properly reference the dropdown field's value in the conditional statement.
Use the form data method to access the dropdown's selected value and structure your conditional logic to check for each possible value.

Answered
Fr FreeSandwiches 02 Nov, 2014
Hey there. I'm a bit of a noob so I apologize if this is an obvious question. I am trying to query a database based on the chose from a drop down menu in the same form so it looks like this.

<?php

if(dropDownOption === 0)
return array("Author" => $form->data("userinputfindabook"));

if(dropDownOption === 1)
return array("book title" => $form->data("userinputfindabook"));

if(dropDownOption === 2)
return array("ISBN" => $form->data("userinputfindabook"));

?>

The problem is I don't know how to write the condition of the if statement.
Max_admin Max_admin 03 Nov, 2014
Answer
Hi,

It should be like this:

<?php
if($form->data("dropdown_field_name") == 0){
return ...
}else if($form->data("dropdown_field_name") == 1){
return ...
}else if($form->data("dropdown_field_name") == 2){
return ...
}


Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.