为动态文本框创建新的会话变量

时间:2015-01-16 06:59:46

标签: javascript php

点击该框,使用javascript附加新文本框。现在我想捕获输入并创建输入的新php会话变量我该怎么做?

这是我的代码:

<input onClick="myFunction();" type="checkbox"/>Demote to Child
<span id="DemoteContainer">// add textbox onclick here //</span>
<script>
//add textbox function
function myFunction()
{
var span = document.createElement('SPAN');
span.innerHTML = '<input id="demo" name = "demo" type="textbox" />';
document.getElementById("DemoteContainer").appendChild(span);
}
</script>
<?
{
$_SESSION['temp']=$_POST['demo'];
}?>

这不起作用我该怎么办?

1 个答案:

答案 0 :(得分:0)

在开始使用$ _SESSION变量之前添加此session_start();