Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

JSP and Javascript problem

Posted on 2002-05-15
1
198 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

This article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to Active Directory
Many businesses neglect disaster recovery and treat it as an after-thought. I can tell you first hand that data will be lost, hard drives die, servers will be hacked, and careless (or malicious) employees can ruin your data.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

856 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