Solved

Reload the jsp page with different parameter

Posted on 2003-11-10
12
2,053 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

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

Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
In this article, I will show you HOW TO: Perform a Physical to Virtual (P2V) Conversion the easy way from a computer backup (image).
This video discusses moving either the default database or any database to a new volume.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 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

10 Experts available now in Live!

Get 1:1 Help Now