Forums

Newbie - How to make a Regular button work

Steven.Fernstar 04 Feb, 2013
Hi All,
I am new to Joomla and Chronoforms but it looks like it is what I am after.
I have no PHP or Java experience but heaps of VB etc.
BUT I am missing big pieces of the puzzle.

I have created a simple form (as per the video tutorials). I can create new records in a table and retrieve a record on load of the form.

What I cannot do is put a regular button on the form and retrieve a record when the user clicks on the button.
In fact I cannot even get the button to display 'Hello World' when clicked on.
I am obviously missing something.
Can somebody post some sample code that will allow me to display a 'hello World' message when the user clicks on the button.

Thanks in advance.
GreyHead 04 Feb, 2013
Hi Steven,

I'm sorry but I don't understand your question?

You want this button in the form? Or as a separate form?

How would it 'know' which record you want to display?

Bob
Steven.Fernstar 06 Feb, 2013
Hi,
The button is on the same form as the submit button.
It is just a simple example where I want to learn how to put code on the click event of a 'non-submit' button.
The code will do something like populate a field on the screen or echo back 'Hello World' (it doesn't really matter for this example).

I just don't understand how object events can be added to the form.
Also, how can I find out what other events Chronoform objects (like buttons, fields etc.) can have?

Thanks
GreyHead 07 Feb, 2013
Hi Steven,

You can attach any JavaScript event; plus code your own to any form element. The general MooTools format is
element.addEvent('event_name', function() { . . . });
So an alert on a button might be
$('button_id').addEvent('click', alert('Bananas');
See here for more info.

Bob
This topic is locked and no more replies can be posted.