php - Passing two variables onclick back to same page -


i need able click on list element , depending on clicking, 2 variables displayed on same page.

i have 2 variables defined in html code ( changed hardcoding them variables html ):

<ul>     <li><a href="#" onclick="('6','67')">text 1</a></li>     <li><a href="#" onclick="('22','240')">text 2</a></li>     <li><a href="#" onclick="('34','56')">text 3</a></li> </ul> 

later pick both variables php $_post this:

<?php     echo $_post['var1'];     echo $_post['var2']; ?> 

how can achieve that?

you this:

<ul>     <li><a href="#" onclick="myfunction('6','67')">text 1</a></li>     <li><a href="#" onclick="myfunction('22','240')">text 2</a></li>     <li><a href="#" onclick="myfunction('34','56')">text 3</a></li> </ul>  <script>    function myfunction(a, b){       $.ajax(function(){           url: <yoururl>,           data: {'a': a, 'b': b }           success: function(){                //access variables here.            }        });    }  </script> 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -