通过JavaScript变量到PHP POST [英] Pass Javascript Variable to PHP POST

查看:104
本文介绍了通过JavaScript变量到PHP POST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  <一href="http://stackoverflow.com/questions/133925/javascript-post-request-like-a-form-submit">JavaScript POST请求就像一个表单提交

我在JS,我想传递的输入表单PHP脚本的一部分计算的值。我怎样才能得到一个值的JS值到PHP作为一个POST参数?

I have a value calculated in JS that I'd like to pass as part of an input form to a PHP script. How can I get a value the JS value to the PHP as a POST parameter?

基本上,在提交,我需要的变种通过邮寄传递给下一个脚本。

Basically, on submit, I need the total var to be passed via post to the next script.

浮现在脑海的第一个想法是创建一个具有价值,并输入与形式的无形投入的形式,这可能吗?

The first idea that comes to mind is create an invisible input form that has the value in it and is inputted with the form, is that possible?

推荐答案

是的,你可以使用&LT;输入类型=隐藏/&GT; 并将其值设置在JavaScript code隐藏的领域,所以它被张贴与其他形式的数据。

Yes you could use an <input type="hidden" /> and set the value of that hidden field in your javascript code so it gets posted with your other form data.

这篇关于通过JavaScript变量到PHP POST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆