Solved

Reload the jsp page with different parameter

Posted on 2003-11-10
12
2,062 Views
Last Modified: 2006-11-17
OK,  I've done this before but now I'm getting some funky error

check this out

<table width=100% border=1 bordercolor=blue>
  <tr>
    <td width=25% align=center>
                        <form name=frmAllowed>
                                    Authorized Users<br>
                                    <select name=selAuth size=8
onChange="doucument.location.href='admin.jsp?person=0'">
                                    <%...
The problem I'm having is with the onChange event of the button.  I need to reload the same page with the value from a select control.  I'm using 0 as a test.  The error I'm getting is

Object required: 'document'

I also need to know how to get the value of the select control named selAuth

Thansk
0
Comment
Question by:dds110
  • 5
  • 4
  • 3
12 Comments
 
LVL 15

Expert Comment

by:jimmack
ID: 9718470
doucument

Just a typo I think ;-)
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9718490
Isn't it

this.form.selAuth
0
 
LVL 3

Expert Comment

by:evedder
ID: 9718906
if you want to get the value with javascript
    this.form.selAuth like jimmack said
if you want to get the value in JSP  
    String var = request.getParameter("selAuth");

and try using window.location instead document.location (by the way, maybe is nothing but in the code you post you wrote doucument instead document)


salu2!
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9718919
>> try using window.location instead document.location

(I'm no JavaScript guru ;-))  Is this to do with browser compatibility?
0
 
LVL 8

Author Comment

by:dds110
ID: 9722303
OK,

"document.location.href='admin.jsp?person=this.form.selAuth'"

returns the literal string in my address

http://myserver/FormsRepository/admin.jsp?person=this.form.selAuth

Is this correct?
0
 
LVL 8

Author Comment

by:dds110
ID: 9722306
by the way, I have several forms on this html page
0
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.

 
LVL 15

Accepted Solution

by:
jimmack earned 50 total points
ID: 9722859
Try:

document.location.href='admin.jsp?person=' + this.form.selAuth
0
 
LVL 3

Expert Comment

by:evedder
ID: 9723272
the object document has an array of forms whose index start with 0 so, if you have your var selAuth in the first form of your page you have to write

http://myserver/FormsRepository/admin.jsp?person=this.form[0].selAuth

if is in the second

http://myserver/FormsRepository/admin.jsp?person=this.form[1].selAuth

and so on.
0
 
LVL 8

Author Comment

by:dds110
ID: 9723989
tried jimmack's suggestion

Now I get

http://dschleifer/FormsRepository/admin.jsp?person=

Tried evedder's suggestion; same outcome

I try not to post tons of code, but would anyone mind if I did?
0
 
LVL 8

Author Comment

by:dds110
ID: 9724610
OK, just a bit of code then...

<table width=100% border=1 bordercolor=blue>
  <tr>
    <td width=25% align=center>
      <form name=frmAllowed method=post>
      Authorized Users<br>
      <select name=selAuth size=8
        onChange="document.location.href='admin.jsp?person='" + document.frmAllowed.selAuth.selectedIndex + "'">
<!-- the preceding line needs to pick up the selected value of the select box and then requery the server for admin.jsp passing the value to the variable person -->
        <%
        try{
        db.query(strAllowed);
        while(db.nextResult()){%>
        <option value=<%=db.getIntFromResult("intUserID")%>><%=db.getStringFromResult("NAME")%></option>
        <%}
        }
        catch(Exception ex){out.println(ex);}
        %>
        <option value=9999>
<!-- this for loop provides spacing only for the select control -- >
        <%for(int x=0;x<20;x++){%>
            &nbsp;<%}%>
        </option>
      </select>
      </form>


It is this line:

onChange="document.location.href='admin.jsp?person='" + document.frmAllowed.selAuth.selectedIndex + "'">


That I need to get the value from.  Any ideas?  The rest of the page works as expected.
0
 
LVL 3

Expert Comment

by:evedder
ID: 9725152
what you have to do is:

let's naming the code you post as "index.html"

as selAuth is inside a form you dont have to pass his value within the url so, the line would be

onChange="document.location.href='admin.jsp'


in "admin.jsp" you need to get selAuth so, you need this line

String varname = request.getParameter("selAuth")

this assign the value you have selected in selAuth in index.html to varname in admin.jsp so you can use this variable.


If the index.html and the admin.jsp is the same page is the same procedure try it
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9741449
Thanx ;-)
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
Problem with Pie chart in Jsp 20 206
Export JSON response data to Excel in IE9 3 67
Handle form fields in spring mvc controller 1 60
struts exact match support 3 51
Large Outlook files lead to various unwanted errors and corruption issues. Furthermore, large outlook files can also make Outlook take longer to start-up, search, navigate, and shut-down. So, In this article, i will discuss a method to make your Out…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

920 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

12 Experts available now in Live!

Get 1:1 Help Now