Solved

Reload the jsp page with different parameter

Posted on 2003-11-10
12
2,102 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
Independent Software Vendors: 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

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
unit test DAO layer 1 142
J2SE 5.0 metadata 1 67
TreeSet comparator example 7 103
Handle form fields in spring mvc controller 1 70
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

762 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