How can I pass variables from JavaScript to PHP?

后端 未结 2 958
庸人自扰
庸人自扰 2020-11-29 13:51

I am using jQuery to calculate prices. Here is a small snippet of my JavaScript:

// Prices: radio
var curLam = \"gloss\";
$(\"input[name=lamination]\").click         


        
2条回答
  •  遥遥无期
    2020-11-29 14:25

    Generally speaking, you shouldn't return the selected price to the server. HTML forms can be easily faked. It is far safer to send the user's choice back to the server, which also knows how much it should cost.

    Basically Javascript validation (which this essentially is) is convenient but shouldn't be trusted. You already have an input for selecting the finish. Just send that back to the server. That way your site will still work (or work better) if the user has Javascript disabled.

提交回复
热议问题