我使用 CGI C 并尝试在表单中使用组合框。当我更改所选值并按保存按钮时,在提交表单之前我可以看到所选值更改。它总是变成 7。我不知道为什么。这是我的代码:
<form method=POST action="cgi-bin/aa.cgi?aa.xml" name="aform" onsubmit="return checkConForm(document.aform);">
<table class=conftable>
<td class=conftabletd>
<select name="aa" id="aa" >
<option value=2>2</option><option>1</option><option>3</option><option>4</option><option>5</option><option>6</option><option>7</option>
</select></td>
</tr>
</table><br>
<a href="javascript:submitform(document.aform)" class="more">save</a>
</form>
js:
function checkConfigForm ( form )
{
var selectLists = document.getElementsByTagName("select");
for ( var i=0; i<selectLists.length; i++ ) {
if (selectLists[i].id != null) {
alert(selectLists[i].id);
selectOpts(selectLists[i].id);
}
}
return true;
}
function selectOpts( selectId )
{
var selectList = document.getElementById(selectId);
var selectListLength = selectList.length;
if (selectListLength == 0){
appendOptionLastwValue( selectId, "" );
selectListLength = 1;
}
for (var i = 0; i < selectListLength; i++) {
selectList.options[i].selected = true;
}
return true;
}
function submitform( form )
{
if(form.onsubmit() == true){
form.submit();
}