Selected Jquery, fetching multiple select values โ€‹โ€‹in vbscript / classic asp and ASPupload

I posted a question this morning about the selected jQuery script, which was how can I get values โ€‹โ€‹from a selected jquery multiple choice block with classic asp, someone asked me about the demo code, so when creating it everything seems to work with all the sudden fines and thought you knew I was getting old, however after trying to implement the code, I ran into the same problems, but I think I could find the problem I was facing. Below you will find the code:

This includes 2 selected jquery forms (http://harvesthq.github.com/chosen/), the top is a simple form, the second is a form with upload function, I have included the code below both pages:

Code for 'example.jquery.html'

<!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>

      

=============================================== === =============================================== === =============================================== === ==============

code for 'CollectChosenData.asp'

<!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>

      

Now why will the first form (simple version) return me the correct values โ€‹โ€‹for "ChosenData" and the second form?

Thanks so much for your help and the guys' answers, he says, scratching his head .....

+1


source to share


1 answer


Your problem seems to be that the loading component only shows one of several values.

See Upload.Form returns only the first selected control with multiple selections .



As shown in the workaround, you will have to loop through each named form element ChosenData

and display.

+2


source







All Articles