Solved

Selection Box parameters

Posted on 2003-10-30
5
168 Views
Last Modified: 2010-04-01
Hi All,
 I have two selection boxes in a JSP . I pass values from one selectionbox to the other. Making the second one as the selectedBox.

when I try to retrieve the info in the servlet. I get only one value which is Highlighted.
Could someone let me know how to get all the values.
0
Comment
Question by:aarschie
  • 3
5 Comments
 
LVL 18

Accepted Solution

by:
bobbit31 earned 250 total points
ID: 9653964
there are two ways of doing this... before submitting the form run through each of the options and select them OR
add it to querystring:

if #2
function validateForm(whichForm) {
      var qString="";
      var whichList = whichForm.selYOURSELECT; // *** MAKE SURE TO CHANGE TO THE NAME OF YOUR SELECT BOX
      for (i=0;i<whichList.options.length;i++) {
            qString += ((i==0) ? "?" : "&") + "enrollList=" + whichList.options[i].value;
      }
      newAction = new String(whichForm.action);
      ix = newAction.lastIndexOf("?enrollList");
      if (ix == -1) {
            whichForm.action = newAction + qString;
      } else {
            whichForm.action = newAction.substring(0, ix) + qString;
      }
      return true;
}
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 9653970
and in the onsubmit of your form
<form name=Form1 action="..." method=post onsubmit="return validateForm(this);">
...
</form>
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 9653982
if #1:

function validateForm(whichForm) {
   var whichList = whichForm.selYOURSELECT; // *** MAKE SURE TO CHANGE TO THE NAME OF YOUR SELECT BOX
   for (i=0;i<whichList.options.length;i++) {
       whichList.options[i].selected = true;
   }
   return true;
}

call this the same way as above.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This article describes how to reset your Windows 10 password when you've forgotten it.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question