我想实现以下效果:一个form表单有一个select,两个表格;select页面上用js控制哪个表格显示。比如选择“图片”,则显示图片表格,提交的时候提交select 的值1和图片表格中的数据,请问怎么提交?
<form name="myform" method="post" action="a.php">
<select name="myselect">
<option value="1">图片</option>
<option value="2">视频</option>
</select>
<table>
(填写图片表格)
<button type="button" name="button" onclick="">保存</button>
</table>
<table>
(填写视频表格)
<button type="button" name="button" onclick="">保存</button>
</table>
</form>
function checkButton(button){
var from = document.getElementById("fromid")
if(button.id==‘img’){
//(填写图片)获取以后.style.display='block';
from.action="url";
from.submit();
}else{
//(填写视频表格)获取以后.style.display='block';
from.action="url";
from.submit();
}
}
<form id="fromid" name="myform" method="post" action="a.php">