今天早上我发布了一个关于选择jQuery脚本的问题,这是我能够从经典的asp中选择的jquery多选框中检索值,有人问我演示代码所以在构建它时,一切似乎都有效一切都很突然,并且认为你知道我已经老了,但是在尝试实现代码后我遇到了同样的问题,但我想我可能已经找到了我正在反对的问题。您将在下面找到所涉及的代码:
这包括2种形式的所选jquery(http://harvesthq.github.com/chosen/),顶部是普通表格,第二种是带上传功能的表格,我已经包含下面的代码两页:
<!doctype html>
<html lang="en">
<head>
<link rel="stylesheet" href="chosen/chosen.css" />
</head>
<body>
<h3>Chosen without enctype="multipart/form-data"</h3>
<form action="CollectChosenData.asp?type=plain" method="post" name="ExampleChosen">
<div id="container">
Multiple Select<br><br>
<select data-placeholder="Your Favorite Types of Bear" style="width:350px;" multiple class="chzn-select" name="ChosenData" tabindex="8">
<option value=""></option>
<option value="1">American Black Bear</option>
<option value="2">Asiatic Black Bear</option>
<option value="3">Brown Bear</option>
<option value="4">Giant Panda</option>
<option value="5" selected>Sloth Bear</option>
<option value="6">Sun Bear</option>
<option value="7" selected>Polar Bear</option>
<option value="8">Spectacled Bear</option>
</select>
<br>
<br>
text field:
<input type="text" name="othertext" value="text value">
<br>
<br>
<input type="submit" name="ExampleChosenSubmit" value="Post form">
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script src="chosen/chosen.jquery.js" type="text/javascript"></script>
<script type="text/javascript"> $(".chzn-select").chosen();</script>
</form>
<br>
<hr>
<br>
<h3>Chosen with enctype="multipart/form-data"</h3>
<form action="CollectChosenData.asp?type=upload" method="post" name="ExampleChosenUpload" enctype="multipart/form-data">
<div id="container">
Multiple Select<br><br>
<select data-placeholder="Your Favorite Types of Bear" style="width:350px;" multiple class="chzn-select" name="ChosenData" tabindex="8">
<option value=""></option>
<option value="1">American Black Bear</option>
<option value="2">Asiatic Black Bear</option>
<option value="3">Brown Bear</option>
<option value="4">Giant Panda</option>
<option value="5" selected>Sloth Bear</option>
<option value="6">Sun Bear</option>
<option value="7" selected>Polar Bear</option>
<option value="8">Spectacled Bear</option>
</select>
<br>
<br>
other field:
<input type="file" name="mytestfile" value="">
<br>
<br>
text field:
<input type="text" name="othertext" value="text value">
<br>
<br>
<input type="submit" name="ExampleChosenSubmit" value="Post form">
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script src="chosen/chosen.jquery.js" type="text/javascript"></script>
<script type="text/javascript"> $(".chzn-select").chosen();</script>
</form>
</body>
</html>
=============================================== ================================================== ================================================== =================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<%
If Request.Querystring("type") = "plain" Then
Response.write "Value collected from chosen select box: '"& Request.Form("ChosenData") &"'<br/>"
Response.write "Value collected from text field: '"& Request.Form("othertext") &"'<br/>"
ELseIf Request.Querystring("type") = "upload" Then
Set objUpload = Server.CreateObject("Persits.Upload")
objUpload.OverwriteFiles = False
objUpload.SetMaxSize 1048576 ' Limit files to 1MB
objUpload.SaveVirtual "/upload"
Response.write "Value collected from chosen select box: '"& objUpload.Form("ChosenData") &"'<br/>"
For Each File in objUpload.Files
Response.write File.FileName &"<br/>"
Next
Response.write "Value collected from text field: '"& objUpload.Form("othertext") &"'<br/>"
Set objUpload = nothing
End if
%>
<br>
<br>
Return and <a href="example.jquery.html">try again</a>
</body>
</html>
现在为什么第一个表单(普通版本)会为“ChosenData”返回正确的值而第二个表单没有?
非常感谢你的帮助和回复家伙,他一边挠头一边说......
答案 0 :(得分:2)
您的问题似乎是上传组件只显示了一个选择的多个值。
请参阅"Upload.Form returns only the first selected item of a multi-select control"。
如解决方法所示,您必须遍历名为ChosenData
的每个表单元素并显示。