LZ, bygg的思路是对,主要是你赋值取值可能不对而以`~,试一下下面的符合你要求没?
在后台你就取隐藏域hidCheckBoxValue的值就行了~~~
<script language="javaScript">
//是否有checkbox被选中
function anyBodyChecked()
{
var elements=document.testForm.elements;
var counter=elements.length;
var value="";
for(i=0;i<counter;i++)
{
var element=elements[i];
if(element.checked == true)
{
value+=element.value;
}
}
var hide=document.getElementById('hidCheckBoxValue');
hide.value=value;
document.write(hide.value);
} </script>
<form> 多项选择框列表:
<P>
<INPUT type="checkbox" value="水" name="strBase"> 水
<INPUT type="checkbox" value="电" name="strBase">电
<INPUT type="checkbox" value="煤气" name="strBase">煤气
<INPUT type="checkbox" value="暖气" name="strBase">暖气
<INPUT type="checkbox" value="有线" name="strBase">有线
<INPUT type="checkbox" value="电话" name="strBase">电话
<INPUT type="checkbox" value="宽带" name="strBase">宽带
<INPUT type="checkbox" value="电梯" name="strBase">电梯
<INPUT type="checkbox" value="厨房" name="strBase"> 厨房</P>
<input id="hidCheckBoxValue" type="hidden" runat="server" />
<input id="button" type="Button" onclick="anyBodyChecked()" value="Save"/>
</form>
在后台你就取隐藏域hidCheckBoxValue的值就行了~~~
<script language="javaScript">
//是否有checkbox被选中
function anyBodyChecked()
{
var elements=document.testForm.elements;
var counter=elements.length;
var value="";
for(i=0;i<counter;i++)
{
var element=elements[i];
if(element.checked == true)
{
value+=element.value;
}
}
var hide=document.getElementById('hidCheckBoxValue');
hide.value=value;
document.write(hide.value);
} </script>
<form> 多项选择框列表:
<P>
<INPUT type="checkbox" value="水" name="strBase"> 水
<INPUT type="checkbox" value="电" name="strBase">电
<INPUT type="checkbox" value="煤气" name="strBase">煤气
<INPUT type="checkbox" value="暖气" name="strBase">暖气
<INPUT type="checkbox" value="有线" name="strBase">有线
<INPUT type="checkbox" value="电话" name="strBase">电话
<INPUT type="checkbox" value="宽带" name="strBase">宽带
<INPUT type="checkbox" value="电梯" name="strBase">电梯
<INPUT type="checkbox" value="厨房" name="strBase"> 厨房</P>
<input id="hidCheckBoxValue" type="hidden" runat="server" />
<input id="button" type="Button" onclick="anyBodyChecked()" value="Save"/>
</form>
Knowledge is infinite.