(SOLVED) button element execute a PHP code

Status
Not open for further replies.

jmoises

Active Member
Hello i have add a button element to my form but i didnt find a PHP core area

I need to execute a PHP code when the user click the button

can some body gide me

thank you
 
Remember that PHP runs on the server. The button clicks can only kick off JavaScript in the browser.

What are you trying to do?

One possibility is to add the JavaScript on button click to send an AJAX request to the server, and have a user_ajax.php (see example, in ./components/com_fabrik/user_ajax_example.php), passing it whatever data it needs to do whatever it is you need doing.

But obviously I need more info on what you are doing to provide specific code help.

-- hugh
 
Thanks cheesegrits basicaly what i need to do is this

I have a Group's of competitors, example (Group A) (Group B) (Group C) each group with 250 competitors, what i need to do is To show a Form and have a Element for Group Description / ID (Dbjoin) and a Time element when i Click the button i need to add/update to all the competitors in the selected group the field Start Time with the time previosly selected in the form.

(ufff maybe i need to use the form php process right')
 
Yes, a PHP form submission plugin would probably be what you need.

You could create a table-less form, which just has the those two elements, and a PHP plugin running "onBeforeProcess". In that plugin, you would do something like ...

PHP:
$group_id = $formModel->getElementData('___groupid', true);
$time = $formModel->getElementData('___time', true);
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->update('yourtable')->set('start_time = ' . $db->quote($time))->where('groupid = ' . $db_quote($group_id));
$db->setQuery($query);
$db->execute();

Obviously you'll need to change the table and field names to suit.

Also, I'm not entirely sure what format the 'time' element submits in, so when you get ready to test this, we'll need to put in some debug code to work out what the format is, and tweak the data into the format we need for the update query.

As per another thread, it'll be easier if we can get at your site to help.

-- hugh
 
The way to provide the info is with your "My Sites", which you can get to by clicking the link to the left of any of your posts. That will take you to a form where you can provide site access details and makes notes, that only you and Fabrik staff can see.

-- hugh
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top