Solved

Selection Box parameters

Posted on 2003-10-30
5
167 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jason format for rest webservices and sub resourcing 1 89
getting Http 404 error in jsp forms 8 79
how to exclude a file using regex 5 118
maven j2ee examles 2 55
One of the biggest threats in the cyber realm pertains to advanced persistent threats (APTs). This paper is a compare and contrast of Russian and Chinese APT's.
Employees depend heavily on their PCs, and new threats like ransomware make it even more critical to protect their important data.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 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