JS
function changeFunc() {
var selectBox = document.getElementById("selectBox");
var selectedValue = selectBox.options[selectBox.selectedIndex].value;
switch(selectedValue){
case 'odincova':
document.getElementById("year").innerHTML = '<select name="year"><option value="2000">2000</option><option value="2001">2001</option></select>';
break;
// . . .
}
}
HTML
<table id="myTable">
<form method="post" action="congrat.php">
<tr><td id="year"></td></tr>
PHP
$year=$_POST['year'];
这行不通。我通过Javascript的document.element.innerHTML将值插入到表中,之后我需要通过PHP的post方法获得这些值,但它不起作用。
如果你通过ajax发布文章,并将$('#myTable .CLASS').serialize()
添加为ajax的数据,其中CLASS
是你添加到你想要序列化的内容中的类,我认为它可以在中工作
也如评论中所建议的,将<form
标签移动到<table
之前