CalcBuilder Forum

Get values out of Javascript

Usuario veli 2017-09-28 07:03:34

Hi,
have managed to write values from Javascript into an html form, but can't manage to get them into the fields I had made (php).
I have this code to populate an html form and that is working:
function showCoords(c)
{
CB('#x1').val(c.x);
CB('#y1').val(c.y);
};

The x1 and y1 are the ID's of the form fields. The form is in the 'form layout'.

How can I get these values into the fields I have made so I can print them and send via email?

Hope you can help!

Thanks

Moonsoft support 2017-09-28 18:09:40

Hi,
we suggest to use calcbuilder inputs, instead of creating them by hand at the form, so you will be able to recover them directly at the php section:

- Field configuration: var = myfield
- Input form ##myfield##
- Set one value using javascript: CB("input").val(37);
- At the php code: $myfield

If you dont use calcbuilder fields, then you will have to recover your values using default php code for joomla:

$jinput = JFactory::getApplication()->input;
$value = $jinput->get('yourvarname');

Hope this helps

Usuario veli 2017-10-02 06:43:36

Hi,
thanks a lot for your help, I had not seen your reply!
In the end I have managed to solve the problem.
I had put all my code in the Javascript part just before calculation. The solution was to add everything in the HTML part with its own buttons and now when clicking 'calculate' it can go to the next step and give the result.
I will also look at your solution, but right now it is working OK.

Moonsoft support 2017-10-02 11:30:02

Ok, great it worked, thanks for sharing!

Regards

...
Support/development 10 hours

Get a bigger amount of hours for more complex tasks and get a 10% discount

Buy now!
...
Support/development 40 hours

With the peace of mind of having a professional team at your service (20% discount)

Buy now!