Solved

JSP and Javascript problem

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
form submissions on a web page 2 143
logging jar 1 106
difference between member and local variables. 29 126
report generation frameworks 1 60
There are many Password Managers (PM) out there to choose from. PM's can help with your password habits and routines, but they should not be a crutch you rely on too heavily. I also have an article for company/enterprise PM's.
Note: This is the third blog post in a series on email clearinghouses (https://www.xmatters.com/alert-management/blog-email-has-failed-us?utm_campaign=70138000000ydLoAAI&utm_source=exex&utm_medium=article&utm_content=blog-post).   We’ve been talki…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

910 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

22 Experts available now in Live!

Get 1:1 Help Now