PHP calculation with Sparkle

Hey Sparkler,

First: I have to tell you that I’m having Google translate the text here (from German). So please don’t be surprised if the grammar is wrong ^^

The problem: I would like to create a „total" using the text input fields. I’ve also read that it doesn’t natively support in Sparkle. Would this be possible with PHP?

However, the result should not be sent by email. The only thing that is important to me is that I can see in the e-mail how often which product has been purchased.

Thank you for your answers and greetings from Germany
Bildschirmfoto 2021-11-03 um 10.25.12

Hi @AleXiell,

presumably you would want the total to update live in the page, so what you want is Javascript rather than PHP (which runs on the server so it would require reloading the page, and not be interactive).

It’s definitely something that’s possible with Javascript, and the general idea would be to:

  • add an id for each text input
  • add an id for the total text field
  • add an embed block with the javascript code in it
  • in the javascript code you grab the text input values, perform the calculation, then set the result in the total text field

This is something that is not trivial if you don’t code, and teaching to code is not really the purpose of this forum, but just to say it’s not impossible.

Hello.

I suppose you want to set up a shop on your website.

You better take a third party webshop software and embed it into your site. This way you will surely meet some legal requirements: Terms of contract, revocation and so on.

You won’t get far with the simple form from Sparkle.

Mr. F.

1 Like

Thank you for your quick reply! This is a good starting point :slight_smile:

Maybe this feature would be interesting for later versions of Sparkle. (Crossover Smart-/ and Textfields)

Liebe Grüße aus Australien, ich habe Erfahrung mit JavaScript und php. Erinnere mich per private message dann kann ich versuchen mich mal rein zu denken.

Michael