Solved

Reload the jsp page with different parameter

Posted on 2003-11-10
12
2,073 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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
 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to group array of objects ? 5 65
difference between member and local variables. 29 134
servlet init param and contect param 3 65
Set up Wildfly 10 8 396
In this article we will learn how to backup a VMware farm using Nakivo Backup & Replication. In this tutorial we will install the software on a Windows 2012 R2 Server.
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

809 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