How to call UDT onclick event?
How to call UDT onclick event?
I need to call my User Defined Tag on button click event. How to do it?
-
- Forum Members
- Posts: 10
- Joined: Wed Jun 05, 2013 8:19 pm
Re: How to call UDT onclick event?
You posted on wrong topic put I hope admins move this post correct topic.
I tested it and its should work and next time do just some basic Googeling like "javascript onclick"!
btw. <__script__> is without __ forum add this
Code: Select all
<button onclick="myFunction()">Click me</button>
<p id="demo"></p>
{literal}
<__script__>
function myFunction() {
document.getElementById("demo").innerHTML = "{/literal}{root_page_id}{literal}";
}
</__script>
btw. <__script__> is without __ forum add this
Re: How to call UDT onclick event?
Your advice is not good to me. My UDT:
So, UDT executes after loading a page, but not after click on a button... Param cid sets when an user click on button, but UDT executes after loading a page...
Code: Select all
$cid = (int)$params['cid'];
$db =& $this->GetDb();
$query = 'DELETE FROM cms_module_cgfeedback_comments WHERE id = ?';
$res = $db->Execute($query, array($cid));
Code: Select all
{literal}
<__script__>
function del(ans){
document.cookie = "a="+ans;
{/literal}
{del_ans cid=$smarty.cookies.a}
{literal}
document.getElementById('user_answer_'+ans).innerHTML = ans;
}
</__script>
{/literal}
Re: How to call UDT onclick event?
You can't a UDT is server side so a click event would have to make a call to the server either by loading another page or using Ajax,
Re: How to call UDT onclick event?
yes, as applejack says, call new page using ajax, that works
[a href="?page=blank&showtemplate=false"]Calling to UDT[/a]
this link calls blank page which just have in content an udt
[a href="?page=blank&showtemplate=false"]Calling to UDT[/a]
this link calls blank page which just have in content an udt