How do i populate a dropdown box in jsp?

Can someone write some code that takes 15 string values (passed to the jsp in the URL) and puts them in a dropdown select box (or combo box i think they're called).
I've trawlled around looking on the forums but I cant get my code to work the way I need it to.
Cheers

I'll assume that the values are passed in as parameters named param0, param1 etc:
<select name="mySelect">
<%
for(int idx = 0; ; idx++)
  String param = request.getParameter("param" + idx);
  // We've run out of parameters
  if(param == null)
    break;
%>
  <option value="<%= idx %>"><%= param %></option>
<%
%>
</select>This will generate some HTML along the lines of:
<select name="mySelect">
  <option value="0">Value 0</option>
  <option value="1">Value 1</option>
  <option value="2">Value 2</option>
</select>If your values contain HTML markup (<, >, etc.) it won't work so well but that's easily fixed.
Hopefully it won't be too hard to change this to meet your requirement.
Hope this helps.

Similar Messages

  • How can I make a dropdown box populate with values from other fields?

    I am trying to create a NCAA bracket where they select teams from a dropdown menu. For example, they choose which teams win in game 1 and 2 through a dropdown box. The winner of games 1 and 2 then play each other, so how can I populate the dropbox with their selections for game 1 and 2?
    Game 1 winner --
         (game 9)        |--- Game 9 winner
    Game 2 winner --
    Game 9 winner needs to populate with their selections from game 1 winner and game 2 winner.

    I would look at using the setItems Acrobat JavaScript method.
    Have you considered using  a Mouse Up action for "Game 1" and "Game 2" to fill "Game 9"

  • How to populate a dropdown box based on a selection in another Dropdown box.

    I am trying to find out a way to do the following:
    I am using coldfusion ....working on a form. The form has
    couple of dropdown boxes. Based on the selection on the first
    dropdown box another dropdown box needs to get populated with
    different options. These options will be coming from a query. I am
    trying to find out the Javascript code for doing this.
    Thanks in advance.

    jchopra,
    There's a method to doing what you're wanting to do that I've
    used extensively.
    Basically, within my code, I start by invoking the method
    that returns the data for the dropdown lists. Then, I use the
    following code to pour the data returned into a javascript array:
    var locArray = new Array(#evaluate(locs.recordcount+1)#);
    locArray[0] = new Array('','','','','','','','','',);
    <cfloop query="locs">
    locArray[#locs.CurrentRow#] = new
    Array('#JSStringFormat(locationId)#',
    '#JSStringFormat(fkyPolicyId)#',
    '#JSStringFormat(locationNumber)#',
    '#JSStringFormat(description)#',
    '#JSStringFormat(address1)#',
    '#JSStringFormat(address2)#',
    '#JSStringFormat(zipcode)#',
    '#JSStringFormat(city)#',
    '#JSStringFormat(state)#';
    </cfloop>
    Then I wrote a javascript function that is assigned to the
    first dropdown's onChange() event. When the user changes the value
    that is selected within the dropdown, I use javascript to locate
    (using the policyid) the corresponding record in the javascript
    array and populate and/or select the appropriate value(s) in the
    second dropdown.
    If the data returned from the method invocation is too large
    to use within a javascript array, you may need to limit the results
    that are returned.
    Hope this makes sense. If not, please let me know.
    ds

  • How can I validate a dropdown box to NOT accept the default value?

    I have a fillable form where I need the user to select their "Number of Employees". I have added several ranges as their options in a dropdown box (1-10, 11-25, 26-50, 50+). My issue is the "defult value" is set to "1-10" and people submit it without changing it to the correct value.
    I have changed the default value to "--Select One--", but it still lets them submit the form with that value entered.
    I am assuming I need some sort of validation script that will basically say - "If the value in this field is --Select One-- do not submit the form, but give an error that says 'please select your number of employees" or something along those lines.
    Basically I just want them to pick something as opposed to just submiting it with the default value.
    I have looked all over and am not very good with JS.

    You can not have the default value set to a real possible value. You need a value that should be selected.
    Then for your submit script you need to test all of your required fields to make sure they are not at the default value.
    You make a variable that assumes all the required fields are completed and then check each field and if any one still has the default value you set your variable to "false" and then when you have checked all the fields you test your variable's value and only if it is true to you submit the form.
    var bSumbit = ture; // logical variable for submission test
    // test drop down # of employess
    this.getField("Number of Employees".).required = false; // clear required property
    if(this.getField("Number of Employees".).value == "--Select One--") {
    bSubmit = false;
    this.getField("Number of Employees".).required = true; // set required property
    if(bSubmit) {
    // your submit acation;
    } else {
    app.alert("Not all required fields properly completed", 0, 1);

  • How can I populate a dropdown list

    I am trying to build a dropdown list dependant on another dropdown list
    Once a selection is made in dropdown list 1:
    Only items associated with that selection are populated in dropdown list 2 AND
    populates text field 1 with the data selected in dropdown list 1
    Once dropdown list 2 selection is made:
    populates a text field 2 with the data selected in dropdown list 2
    Anybody know how this can be done?
    Ray

    Sorry about that. I had the link ready to paste but neglected to do so: http://acrobatusers.com/tutorials/getting-external-data-into-acrobat-x-javascript
    The idea is that you can read in data from an external or attached file, but it will need to be a different format such as XML, tab-delimited text, or CSV, which can all be exported from a spreadsheet.

  • How do I populate one Combo box based on input from another

    Hi,
    I have a dynamic Combo box populated from a database. Now I want to use the onChanged event to dynamically populate a second combo box on the same page.
    Any ideas on how to do this?
    Robert
    [email protected]

    Here is an example:
    let us consider it not coming from the database:
    <html>
    <head>
    <title>New Page 1</title>
    <script>
    function popSub()
    var n = 1;
    var mainValue;
    mainValue = document.test.main.options[document.test.main.selectedIndex].value ;
    if (mainValue=="Age" )
                        document.test.sub.options[n].value = 'below18';
                        document.test.sub.options[n].text = 'Below 18';
                        n =     n + 1;
    if (mainValue=="Age" )
                        document.test.sub.options[n].value = 'over18';
                        document.test.sub.options[n].text = 'Over 18';
                        n =     n + 1;
    if (mainValue=="Sex" )
                        document.test.sub.options[n].value = 'male';
                        document.test.sub.options[n].text = 'Male';
                        n =     n + 1;
    if (mainValue=="Sex" )
                        document.test.sub.options[n].value = 'female';
                        document.test.sub.options[n].text = 'Female';
                        n =     n + 1;
    </script>
    </head>
    <body>
    <form method="POST" name="test">
    <p><select size="1" name="main" onClick="popSub()">
    <option value="Age">Age</option>
    <option value="Sex">Sex</option>
    <option selected>select one</option>
    </select></p>
    <p><select size="1" name="sub">
    <option value=""></option>
    <option value=""></option>
    <option value=""></option>
    </select></p>
    <p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
    </form>
    </body>
    </html>
    If it coming from the database then you have to write the javascript function in jsp as follows:
    out.println('<script language="JavaScript">');
    out.println('function popSub()');
    out.println('{');
    out.println('var n = 1;');
    out.println('var mainValue;');
    out.println('mainValue = document.test.main.options[document.test.main.selectedIndex].value ;');
    // start one for loop from 1 to record count
    out.println('if (mainValue=="' + valuefrom the resultset + '")');
    out.println('{');
    out.println("document.test.sub.options[n].value = '" + value from the result set +"';");
    out.println("document.test.sub.options[n].text = '"+value from the result set+"';");
    out.println('n=n+1;');
    out.println('}');
    // end of the for loop
    finish the javascript function using out.println

  • How do I populate one dropdown list based on the selection in another dropdown list?

    I have one dropdown list that has 21 choices.  Depending on the selection of those 21 choices, I have another dropdown list that will select a different subset of choices from a pool of 96 choices.  How do I get this to happen?

    I have one dropdown list that has 21 choices.  Depending on the selection of those 21 choices, I have another dropdown list that will select a different subset of choices from a pool of 96 choices.  How do I get this to happen?

  • How to add checkbox in dropdown box

    hi to all
      please help me urgent
      can we add check box in to the drop down box in screen painter..?
    if yes then please tell me in detail.
    thank you...

    Hi,
    In drop down ( combo box) u can select only one item at a time. so why do u need check box ?

  • How do I populate a list box

    I am using the drag a drop to create a list box. I would like to put my values in the list box. All the tutorials I've seen seem not to address the issue of drag and drop listboxes (where the list box is initialized automatically). Drag and drop list boxes are already populated with default values. I want to place my values in the list box. The generated code is uneditable and this is contributing to my problems.
    Thanks

    SizzlinJones wrote:
    I have coded Swing several years back. I have migrated to other technologies since. I have assignment to create a Messaging application using Linda and eXist database. I really wanted to spend my time dealing with this distributed architecture rather than on GUI issues. I guess I'll just work on the GUI last if time permits.That's probably best. Get a prototype working, then interface it with a GUI at the end.

  • How can I display a confirm box using JSP?

    Dear All,
    I am new to the Java language; please help!
    What I'd like to do is to prompt the user, within a loop, to click OK to continue the loop or CANCEL to exit the loop. I've tried to use JavaScript in conjunction w/ Form submittion to handle the parameter passing ('true'/'false') of the confirm box to a JSP. Yet, every form submission will cause the JSP page to re-load from the top which is the incident I'd like to avoid.
    Is there anyway I can have a confirm box written using JSP? Please help!!
    Thanks,Wing.

    if you do any modifications in the jsp page the whole page will be refreshed to show the latest result after modification.
    if you dont want the whole page to be refreshed
    you can pass the control to another page after the confirm box or you can use frames to your interest.

  • 2 questions about Dropdown Box Item

    Hi all,
    I just started using Design Studio and I have two questions about the Dropodown Box Item (well actually it's more about scripting...):
    - in the startup script of the application I want to populate one dropdown box with master data values of the infoobject 0FISCPER, how can I realize that? (if I use "DS_1.getMemberList...." I get only the values of 0FISCPER for which there is transaction data)
    - as a datasource I use a query with 2 variables:
         - Is it possible to populate these 2 variables with default values and skip the initial Variabile Initialization Screen?
         - I use 2 dropdown box items to set the values of these 2 variables. For one variable everything it's ok (I select the value in the dropdown and the      script populate the variable with that value and the data in the crosstable changes accordingly) but for the other variable associated to the 0FISCPER      infoobject when I select the value in the dropdown it's seem that nothing happens since the Variabile Initialization Screen pop-up and an error says that      I have to select a value for the variable. I did the same simple scripts for the these 2 variables, why does it work for one variable and not for the other?
    Thanks,
    Michele

    I answer myself about one question:
    "Is it possible to populate these 2 variables with default values and skip the initial Variabile Initialization Screen?"
    Yes, it's possible to create a script in order to populate the variables in the event "On Variable Initialization" of the Application and set false to the property "Force Prompts on Startup".

  • How to dynamically populate a listbox with the values in the database

    Hi,
    How do dynamically populate the list box with the values in the oracle database. I want to load the list box at run time.Plz anybody help me out to find a solution for this problem.
    Thanks in advance...
    Regards,
    Shiva.

    u can wite code like this..on jsp page
    <%
    ResultSet rs = stmt.executeQuery("select vender_name from vendors");
    %>
    <select name = "vendorlist">
    <%
    while(rs.next()){
    String vname = rs.getString(1);
    %>
    <option value="<%=vname%>"><%=vname%></option%>
    <%
    rs.close();
    %>

  • How to automatically populate text boxes from dropdown and tick box options and then sum the results

    Firstly I need to say that I have no knowledge of how to use Javascript.
    I am using the 30 day trial of Adobe Acrobat XP Pro to see if it can be used for a Membership Application Form for the 1st year of membership. This 1st year  has a pro-rata membership fee per month left in the year of application along with a pro-rata postage fee for non-UK members. All of the input will be via basic text boxes with the exception of the application date and overseas postage for which I have created 3 dropdown boxes, one for Day, one for Month and one forYear and for the 2 tick boxes which are there for the applicant to say if they want 2 other options which have a cost attached to them.  I want to populate 2 text boxes from the Month lookup. One of these is for the pro-rata membership fee and the other for the pro-rata overseas postage. The other 2 optional items will be text boxes populated from the tick boxes. Having populated these 4 text boxes I then want to have them automatically summed to give the total to be sent by the applicant.
    I have searched many forums and tried many of the suggested ways of doing it and none of the 4 text boxes are populated.
    Are you able to help me with this?
    Many thanks

    The script solution provided is a "custom calculation JavaScript" not a "simplified field notation".
    The comment at the top of the code:
    // Custom calculate script for text field
    should help clarify the placement location for the code.
    Simplified field notation has a number of specific restrictions. One is that the provided data must be numeric data only.

  • How to Populate a Dropdown field for a table control with different keys

    Hi All,
    I have Table control with abt eight columns (fields). Out of these eight field one field is with dropdown list. In table control Project ID is Primary key column. Depending upon this Project ID value, i have different values which is to be populated in dropdown boxes. In table control if there is only one project ID value say 'P000715' i can populate it but when i have more than one project ID (P000715, p000716, P000717.....) in display in rows of table control i want to have different values in my dropdown field corresponding to that row of project id. Experts please tell me how to achieve this functionality.
    Thankx in Advance
    Rizwan Ahmad Siddiqui

    The only way you may be able to do this is using
    MODULE PROCESS ON VALUE-REQUEST. User-programmer F4 help
    in your PAI routine.
    In this routine you would build the list and get the returned value to update the field.
    Something like this.
      DATA: BEGIN OF value_tab OCCURS 0,
        field1 TYPE zlmltype,
        field2 TYPE zltypex,
      END OF value_tab.
    * Drop down values
      REFRESH it_return_tab. CLEAR it_return_tab.
      REFRESH value_tab. CLEAR value_tab.
      SELECT ltype ltypex
        INTO TABLE value_tab
        FROM zlmltyp
        WHERE auth NE '9'.    "System Only
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
           EXPORTING
                retfield   = 'FIELD1'
                value_org  = 'S'
           TABLES
                value_tab  = value_tab[]
                return_tab = it_return_tab.
      READ TABLE it_return_tab INDEX 1 INTO wa_return_tab.
      CHECK sy-subrc EQ 0.
      p_pleadtyp = wa_return_tab-fieldval.

  • How to populate one dropdown on select of other dropdown in a table

    Hi
    My requirement is that I want to populate one dropdown on selection of some value in other drop down.The two dropdown are present in two columns of a Table.
    Can any body help for the same.
    Regards
    Nitin

    Hi,
    Try This
    Bind "enable" properties of Both DD1 and DD2 to
    context attributes of type boolean. DD1Enable,DD2Enable
    1: set their value to false intially 
      wdContext.currentContextElement.setDD1Enable(false);
      wdContext.currentContextElement.setDD2Enable(false);
      Bind the selected property of the table to a
      Context attribute of type boolean(Initially false), say "selected"
    2: Then use check box in the table to get current lead selection
      write in "onToggle" action  of checkBox
    int len=wdContext.nodeTable().size();
    for(int i=0;i<len;i++)
             if(wdContext.currentTableElement().getSelected()==true)
                 wdContext.currentDD1Element().setDD1Enabled(true);
                 wdContext.currentDD2Element().setDD2Enabled(true);
             }else
         wdContext.currentDD1Element().setCountryEnabled(false);
         wdContext.currentDD2Element().setStateEnabled(false);
    This is how u get leadselection and able to change particular row in the table
    Regards
    Lakshmi

Maybe you are looking for

  • 8600 GT with a HDTV

    I have a MSI 8600 GT (passive cooled model) and tried to hook it up to a 37 inch hdtv. The tv supports 720p resolution. I used a video out to composite cable that came with my card and a standard composite cable to hook up to the tv. With the tv on c

  • Playlist missing from match

    my main playlist from itunes is not appearing on match 2 of my smaller ones are , how can i get my main one to appear?

  • Cant connect to server opening DW CS6

    I get a weird "there was a problem connecting to server" error when launching dreamweaver CS6.  But the server it is trying to reach is my old computer.  I can't find any reference to the old computer in any preference or site definition.  where is t

  • [OT] surprising instance variable initialization exception behavior

    No real question here. Just something that caught me quite off guard. I thought I understood the object instantiation process pretty well, but there's clearly at least one significant gap in my knowledge. Not surprisingly, the following gives "Error:

  • Costing Variant for refurbhsiment order

    Hi, I have settting up refurbishment order. will the costing variant would be different for ref.order from normal maintenance order? Please advise! Regards, Meghana