Solved

JSP and Javascript problem

Posted on 2002-05-15
1
193 Views
Last Modified: 2010-04-01
I have a JSP page with a table of n rows.  Each row has the option of having
a dropdown list appear on that particular row.  The user should have the
ability to make a selection from the drop down list and have the page change
to the correct page automatically or it can allow the user to change and
have them click on a link that passes the value of the select box as a
parameter to the proper page.

The problem is that each row CAN NOT be in it's own form.  The action for
the current form is NOT the action I want the select box to use.

I can't seem to figure out how to get the value of the select box in
javascript passed as a parameter using a JSP variable.

Example code:
<form method="post" action="/index.jsp">
  <table>
   <tr>
    <td> Remove Row? </td>
    <td> View Options? </td>
    <td>  Name </td>
   </tr>
   <tr>
     <td> <input type=checkbox name='<%=rowNumber %>' value='<%=
someCheckboxValue %>'> </td>
     <td> <select name=selectOptions>
              <option value="option 1">option1</option>
              <option value="option 2">option2</option>
              <option value="option 3">option 3</option>
            </select>
             &nbsp; View Option &nbsp;
      </td>
      <td> <%= rowName %> </td>
    </tr>
   <tr>
     <td colspan="3"> <input type=button name='UpdateExampleForm'
value='Submit'> </td>
   </tr>
 </table>
</form>
0
Comment
Question by:sapientconceptions
1 Comment
 
LVL 12

Accepted Solution

by:
ahosang earned 100 total points
ID: 7012674
In <head>:
<script>
function goTo(val) {
  location.href="yourJspPage.jsp?parameter="+val;
}
</script>

In table:
<td> <select name="selectOptions" onchange="goTo(this.options[this.selectedIndex].value)">
             <option value="option 1">option1</option>
             <option value="option 2">option2</option>
             <option value="option 3">option 3</option>
           </select>
            &nbsp; View Option &nbsp;
     </td>
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Hyena v12.2 is now available for downloading and is available in English, French, German and Spanish versions.
Is your company's data protection keeping pace with virtualization? Here are 7 dynamic ways to adapt to rapid breakthroughs in technology.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now