Ok, it seems maybe I've misinterpreted how you actually should develop 
with TNTNET (ok, I'm a little stupid and lazy :) ).

I've made one main ECPP file, which calls functions to dynamically print 
data of the webpage (as you did no recommend).
I.e. from main ECCP file I call TO_HTML::dayToHTML(reply.out(), sDay), 
where sDay is a C++ struct I loaded from the database. This function 
will in its turn
print the the current data via reply.out() ostream (as you did not 
recommend).

So now first I will rearrange my code with several ECPP files, so I 
don't need to fill up the <%args> tag with too much variables, i.e. one 
ECPP file for dayToHTML and so on, and see what I can make out of it and 
if it is working as I have planned. :) My goal is to split up the code 
so, for me and others, it is easy to interpret.

Sorry if I may be a little severe in my explanation, it is sometimes 
hard to explain what you are trying to actually do.

On 2015-03-07 10:58, Tommi Mäkitalo wrote:
> Hi,
>
> Ralf is right. He pointed out the starting points.
>
> You have to make familiar yourself with html submit. In tntnet the
> <%args> section defines the parameters, which the user entered to the
> html form. You should use them to ask whether the user pressed the
> submit button. Look at the hello demo or calc demo for very simple examples.
>
> Just a note: In your code snippet you have a std::ostream, where you
> output your html data to. I really suggest not to use the std::ostream
> in tntnet but use the template language ecpp to output html.
>
> Tommi
>
>
> Am 07.03.2015 um 09:54 schrieb Ralf Schülke:
>> Hi Johannes,
>> you found on www.tntnet.org FAQ, Start Guide and Demos.
>>
>> Tntnet used a template language for html tags, you can include your
>> function and more.
>> But read the FAQ for more understanding how tntnet works.
>>
>> Wecome to Tntnet :-)
>>
>> 2015-03-07 9:19 GMT+01:00 Johannes Bergmark <[email protected]>:
>>> Hello!
>>> I know C++ quite well as I've been programming it for hobby purposes in
>>> many years, but I've keeping my hands away of HTML programming (as I
>>> hate it :) ). So all this is quite new for me.
>>>
>>> Anyway, my question is, what is the best practice to call a C++ function
>>> when a user is submitting a form?
>>>
>>> In part of my code it looks like this:
>>> _os       << "<td><form action='TO_HTML::test()' style='display: inline'
>>> id='saveDay'><input type='submit' value='Save'></form></td></tr>"
>>>                << "\n";
>>>
>>> I'm trying to save some user set data to database when the user presses
>>> the save button in HTML form. As you see above the 'TO_HTML::test()' is
>>> the test C++ function I want to call, but I don't know how to  access
>>> this function in HTML code.
>>>
>>> Does TNTNET provide any layers to call C++ functions in HTML code? What
>>> is the most secure way to do this? If not, is it enough to use
>>> Javascript (or should I use AJAX)? I'm not sure about the difference of
>>> these two, but I don't want to study them before I know if they are
>>> required for my purposes.
>>>
>>> Thanks for your help, Johannes.
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Dive into the World of Parallel Programming The Go Parallel Website, 
>>> sponsored
>>> by Intel and developed in partnership with Slashdot Media, is your hub for 
>>> all
>>> things parallel software development, from weekly thought leadership blogs 
>>> to
>>> news, videos, case studies, tutorials and more. Take a look and join the
>>> conversation now. http://goparallel.sourceforge.net/
>>> _______________________________________________
>>> Tntnet-general mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/tntnet-general
>> ------------------------------------------------------------------------------
>> Dive into the World of Parallel Programming The Go Parallel Website, 
>> sponsored
>> by Intel and developed in partnership with Slashdot Media, is your hub for 
>> all
>> things parallel software development, from weekly thought leadership blogs to
>> news, videos, case studies, tutorials and more. Take a look and join the
>> conversation now. http://goparallel.sourceforge.net/
>> _______________________________________________
>> Tntnet-general mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/tntnet-general
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming The Go Parallel Website, sponsored
> by Intel and developed in partnership with Slashdot Media, is your hub for all
> things parallel software development, from weekly thought leadership blogs to
> news, videos, case studies, tutorials and more. Take a look and join the
> conversation now. http://goparallel.sourceforge.net/
> _______________________________________________
> Tntnet-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/tntnet-general


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general

Reply via email to