Solved

JSP and Javascript problem

Posted on 2002-05-15
1
199 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
[X]
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
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Suggested Solutions

Original post  on Monitis Blog. Web performance monitoring is broken into two camps: passive and active. Passive monitoring is defined as looking at real-world historical performance by monitoring actual log-ins, site hits, clicks, requests for…
Read the original post on Monitis Blog. Believe it or not, the most important thing about the website of your business is not what’s on it but how fast it loads. Yes, that’s right!    As you can see on this infographic (an oldie but goodie!), …

726 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