HTML + JS + php ?

26 views
Skip to first unread message

Daniel

unread,
May 9, 2012, 4:13:51 PM5/9/12
to joomla-...@googlegroups.com
Hi all,

I create a new component and I need to include a JS function in a HTLM code to execute a php file....

I suppose that I must write it this way :

HTML : <input type="button" value="<?php echo JTEXT::_('NEXT'); ?>" onclick="name_of_my_js_function(); set_spans_show('sp_number3','','sp_number4','next');" >

JS : function name_of_my_js_function ()
{
????
}

php : my_file.php

My question is : what should I write in the JS code to execute my php file ?
I do not need to display anything on the screen, just need to execute it in backend.

Thanks in advance for your helping hand.
Regards


piotr_cz

unread,
May 11, 2012, 7:45:25 AM5/11/12
to Joomla! CMS Development
Hi Daniel,
If you want user to stay on the same page, probably you want to send
an Ajax request

onclick="new Request({ url: 'uri_of_php_file.php'}).post();"

This is very simplified (you won't know if request succeeded, or what
is the response), more info: http://mootools.net/docs/core/Request/Request

Just keep in mind that the user has to be logged in the backend and
have appropriate priviledges, or ACL will block the action.

Peter


On May 9, 10:13 pm, Daniel <daniel.iguera...@gmail.com> wrote:
> Hi all,
>
> I create a new component and I need to include a JS function in a HTLM
> code to execute a php file....
>
> I suppose that I must write it this way :
>
> _*HTML*_ : <input type="button" value="<?php echo JTEXT::_('NEXT'); ?>"
> onclick="/name_of_my_js_function()/;
> set_spans_show('sp_number3','','sp_number4','next');" >
>
> _*JS*_ : function /name_of_my_js_function ()/
> {
> ????
>
> }
>
> _*php*_ : my_file.php
Reply all
Reply to author
Forward
0 new messages