How to save javascript variable in php

I want the store value clickede_idin to $id2[]give me some suggestions, as well as some preliminary data

function yes(clicked_id)
    {

        var it1=clicked_id;

        alert(it1);

        var tt1=1;


        var tt2= "<?php echo($id2[var it1]); ?>";


        //var tt2=document.getElementById("idcheck").value;
        alert(tt2);
        var tt3=document.getElementById("idcheck1").value;
        //alert(tt3);

    }
+4
source share
2 answers

When you develop a web application, you create tools for exchanging data between a client and a server (using the HTTP protocol). This post is based on requests and responses.

, . PHP , . - HTML (+ javascript). , reponses - , .

, , , :

function yes(clicked_id)
    {

        var it1=clicked_id;

        alert(it1);

        var tt1=1;


        var tt2= 3; // or whatever value returned by php

        var tt2=document.getElementById("idcheck").value;



        var tt3=document.getElementById("idcheck1").value;
        // ajax call here

    }

: javascript php ( ), . ( ) ajax .

ajax, , jQuery $.ajax ( - ) XMLHTTPRequest, javascript - .

0

PHP . JS . , , PHP , JS . - PHP JS .

, , JS PHP script ( echo "<script>var s = 'from php'</script>"), JS NEXT-php-. ajax .

, : Javascript PHP ?

0

Source: https://habr.com/ru/post/1623519/


All Articles