Solved

Reload the jsp page with different parameter

Posted on 2003-11-10
12
2,119 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
[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
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
netstat -a in AIX unix 8 59
issue with pdf generation 2 98
parse example 13 98
caughtSpeeding java challenge 16 141
Unified and professional email signatures help maintain a consistent company brand image to the outside world. This article shows how to create an email signature in Exchange Server 2010 using a transport rule and how to overcome native limitations …
An introduction to the wonderful sport of Scam Baiting.  Learn how to help fight scammers by beating them at their own game. This great pass time helps the world, while providing an endless source of entertainment. Enjoy!
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Suggested Courses

734 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