-3

how can i send variable from java script function and use it for a function of PHP?

enter code here
<script>
    function showpopup(var1){
        document.getElementById('popup').style.display='block';
        document.getElementById('mane').value=var1;
    }
</script>
  • Generally with a POST or GET – Shmiddty Feb 13 '13 at 17:07
  • 1
    here is an old thread ... http://stackoverflow.com/questions/1917576/how-to-pass-javascript-variables-to-php – henser Feb 13 '13 at 17:07
  • From javascript to PHP. Probably with Ajax. I don't really see a variable in the code (maybe var1)? – adeneo Feb 13 '13 at 17:08
  • 1
    generate a string like this and prepare the php page... youwebsite.com/yourpage.php?var=var1 – Saturnix Feb 13 '13 at 17:08
  • and what variable you want to post? And to which PHP script? and how do you want to send it? and what input are you going to provide? and what output do you expect? exuberance redefined :p – AdityaParab Feb 13 '13 at 17:09

1 Answers1

0

What you are talking about is generally accepted as impossible as JavaScript is client side and PHP is Server Side

That said, if you need some PHP to run after the page has already loaded, then you'll be looking at needing something like AJAX or jQuery's .post() . Look into those, and you'll be able find what you need.

Zak
  • 6,976
  • 2
  • 26
  • 48