Triger php with 'button' element plug-in

Status
Not open for further replies.

Fred04

Member
Hello,

I have a form that I use not really to save some data but to generate some records in my database. I have removed the 'submit' button and created my own button element that I called 'generate'

Each time the user click on 'generate', I want to populate a 'calendar' table. Actually I want to insert some dates based on the parameters specified in my form (ie: year = 2012 and periodicity = every Monday --> the result would be to insert about 52 dates in my table). Then it would be good to have an 'alert' to confirm this is done.

I can trigger a JS 'on click' but how do I redirect that to some php instructions? where should I save my php file?

Explanations are welcome and I will update the wiki with the solution.
 
Sounds like you could do something with an ajax routine.

Have a look at components\com_fabrik\user_ajax_example.php. In that file there is a couple of js examples and the some php code, (function userExists).

The phpcode is where you would run your mysql insert.

Ideally you shoudl set up a js action for the onclick just to call a function something like docalendar().

Create a file in components\com_fabrik\js and call it form_x.js where x is the numeric id of your form. In this file you create the routine that sends the data across to the php file.
 
Just shout if you get stuck, although I'm no expert I do have a few ajax routines running.

Whilst I remember, I created a routine for those refreshless links that you mentioned in another thread.

Also if you use any examples on the forums, bear in mind that the JS scripting is different between Fabrik 2.x and 3.x, or at least the mootools AJAX requests.

The mootools pages may come in useful as well, specifially the request page here.

http://mootools.net/docs/core/Request/Request


And finally, you'll probably need to use JSON to wrap the data you are sending to the PHP file.

It sounds a lot more complicated than it is though and I think you are a little more clued up on JS than I am. :)
 
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