mvc在后台怎么获取select下拉框中的所有值 怎么截取想要的值
<script type="text/javascript" language="javascript">
$(window).ready(function () {
$('.SubmitA').bind("click", function () {
var str ;
$('.Select1 option').each(function (i) {
str += $(this).val() + ",";
alert(str);
$(".InputOne").val(str);
});
$('form').submit();
});
})
</script>
<div>
<a href="#" class="SubmitA">提交</a>
<form action="/SelectToDate/Index">
<select id="Select1" name="Select1" class="Select1">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<input class="InputOne" name="InputOne" type="text" />
</form>
这样我在后台获取的值就是 undefined1,2,3,4,5,
我怎么取出1 2 3 4 5啊
------解决方案--------------------
<script type="text/javascript">
var str="";
$(function() {
$("#Select1 option").each(function() {
str += $(this).val()+",";
});
alert(str);
})
</script>
给str一个初始值,你哪代码其他地方不要改