Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2003
    Posts
    6

    Wink Unanswered: capture selected option values from list menu

    hi..

    i would like to capture the selected option values from the list menu..

    this is the codings..
    <%
    out.println("<select name='site_name' >");
    out.println("<option>=====Actual Site Name=====</option>");
    for(int i=0;i<actualAL.size();i++)
    {
    out.println("<option>"+actualAL.get(i)+"</option>");
    }
    out.println("</select>");
    %>

    this is where i would like to capture the values.. (its all on the same page)
    <input type="hidden" name="message" value="User: <%=session.getAttribute("adUsername")%> Contract Insert: ">

    thks..

  2. #2
    Join Date
    Aug 2003
    Posts
    40
    Do you mean that you want to place the results of a selection list option
    into the "hidden" object OR do you want to place a value passed into
    this page into the hidden object?

    If the former, use javascript (onChange() event assigned to the
    <select> tag). Do you need a code example?

    If the later, you can obtain your page argument values via the
    servlet's "getParameter()" method.
    Last edited by olerag; 01-02-04 at 11:37.

  3. #3
    Join Date
    Dec 2003
    Posts
    6
    Originally posted by olerag
    Do you mean that you want to place the results of a selection list option
    into the "hidden" object OR do you want to place a value passed into
    this page into the hidden object?

    If the former, use javascript (onChange() event assigned to the
    <select> tag). Do you need a code example?

    If the later, you can obtain your page argument values via the
    servlet's "getParameter()" method.

    hi

    i would like to place the results of a selection list option
    into the "hidden" object.. its all in the same page

  4. #4
    Join Date
    Aug 2003
    Posts
    40
    Then put a little Javascript into your page and on the <select>
    tag (onChange() event) call a function that will place the option value
    contents into the <hidden> object.

    Something like...
    PHP Code:
    <script type="text/javascript">
      function 
    getSelection(obj) {
        for (var 
    i=0i<obj.lengthi++) {
          if (
    obj.options[i].selected)
            
    document.forms[0].myHiddenObj.value obj.options[i].value;
        }
      }
    </script> 
    This assumes your "hidden" object's name is "myHiddenObj" and
    your <select> tag only permits one selection.

    The <select> tag would include...
    <select onClick="getSelection(this)">
    Last edited by olerag; 01-05-04 at 15:11.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •