Javascriptvariable in PHP
Javascriptvariable in PHP
我有一个问题。我在Javascript中有这个for循环,在PHP中有一些Sessionvariables,声明如下:PHP:
$Vorname = $_POST['Vorname'];
$_SESSION['anzahl'.$Vorname] = $_POST['anzahl'];
会话变量不止一个,如SESSION['anzahl'.'div0']
、SESSION['anzahl'.'div1']
、SESSION['anzahl'.'div2']
等
在Javascript中,我想从不同的Sessionvariables
中获得一个循环的值。
如何从js -for循环中获得"i"到PHP回显?还是有更好的方法?JS:
for(var i =0;i<Bestellungen;i++){
Sessionanzahl.push("<?php echo $_SESSION['anzahl'."div".i]?>");
}
谢谢!
将整个php数组作为json传递给javascript变量并合并到其他数组
var phpArray = <?php echo json_encode($_SESSION['anzahl']) ?>;
Sessionanzahl = Sessionanzahl.concat(phpArray);
相关文章:
- 如何“;修复解析错误:语法错误,意外'{'in”用于php
- onclick javascript in PHP
- Ajax Call with Post in PHP
- Javascript's .toString(16) in PHP
- PHP bringing in XML from URL
- jQuery load with php in it?
- Unable to receive something in PHP from XMLHttpRequest's
- "TokenMismatchException in VerifyCsrfToken.php line 53:
- Cookie grabber in Php or javascript
- 如何使用PHP / CURL / Javascript等从 mca.gov.in 获取公司详细信息
- php ocibindbyname equivalent in javascript
- Javascript blues in PHP: getElementById & getElementsByC
- Displaying php results in html <div>?
- Php in javascript
- PHP in Javascript using Wordpress
- Using PHP in <script> tag?
- How to load 'admin-ajax.php' in frontend
- php in javascript
- urlencode() from PHP in JavaScript?
- PHP in Javascript for PhantomJS + Highcharts