Azharkamar.com

Get Selected Value from Drop Down List – Fabrik, Joomla

Tutorials
10 Oct 2010
2 comments

I usually create my own PHP scripts for my Fabrik forms, because a lot of the websites I develop require massive customization for most of the form actions.

Things were ok, until I came across this damn drop down list.

I couldn’t get the selected value passed on to the next page using the normal $_POST command.

Cock ah. But I’m good now. :D

Get Drop Down List Selected Value

Ok, if I want to get the value of a form input element, I will usually use this kinda PHP script:

$tval = $_POST['textfield1']; //assign the submitted value to a variable
$ddval = $_POST['dropdownlist1'];

However in Fabrik, you can’t use the $_POST function for drop down lists.
You’ll have to use this script:

$ddval = JRequest::getVar('tablename___dropdownlist1');
$ddval = $ddval[0]; //$ddval stores the selected value

And as usual, to check what value that script fetches by adding this piece of code right below it:
echo $ddval;
exit;

Now go go go, get to work!

Author - Azhar Kamar
2 Comments Revolving around this Article
  1. Baud

    Just what I was looking for. However, I have no clue in which file I should insert the code. A hint would be appreciated. :-)



    Azhar Kamar replied:

    Hello Baud! You have to put the code in your own PHP file. Then call the file when you submit the form. I assume you know how to use Fabrik’s form submission plug-ins.

Write a Comment! NOW! :)

Current ye@r *