aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Question about forms Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Question about forms" Watch "Question about forms" New topic
Author

Question about forms

Michael Raymond Jr.
Ranch Hand

Joined: May 16, 2005
Posts: 178
I have a page that is two frames, one left, one right.
A servlet that takes a param from the form and writes to a file called output_htm

What I want is that output_htm file to load on the left frame after completion.


It works in that the output_htm file is created and written to by the servlet using the "searchdata" field info. However, after click the CLICK ME button the page goes to the normal blank page. But I don't want it to. If I change the input type from SUBMIT to BUTTON, then the javascript updates the left pane like normal. Of course it doesn't send the input text on the form to the servlet, so nothing is passed to the servlet.

is there a 'best practice' to make the FORM not submit the way it does, yet still pass the servlet the information?


Scooby Snacks for everyone...<br /> <br />SCJA, SCJP 1.4
Michael Raymond Jr.
Ranch Hand

Joined: May 16, 2005
Posts: 178
I can't seem to get my code psoted in the CODE tags, so here goes:

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61657
    
  67

If you don't want the frame containing the form to submit, then set the target of the form to to be the frame in which you do want the response to appear.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Michael Raymond Jr.
Ranch Hand

Joined: May 16, 2005
Posts: 178
Originally posted by Bear Bibeault:
If you don't want the frame containing the form to submit, then set the target of the form to to be the frame in which you do want the response to appear.


thanks. i tried that, but it opens a new window using the fileSearch.zzz as the file to open, and on the original page nothing happens.

is the 'target' in the FORM OR INPUT?? I did it in the FORM and what happens is explained above.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
is this what you did?
<form target="frameName" ....>

Eric
Michael Raymond Jr.
Ranch Hand

Joined: May 16, 2005
Posts: 178
Originally posted by Eric Pascarello:
is this what you did?
<form target="frameName" ....>

Eric


yeah, framename is the ID of the DIV tag righ? does it have to be the NAME attribute? like, <div name="framename"..? I have it as <div id="framename"...which works will all my other code.
Michael Raymond Jr.
Ranch Hand

Joined: May 16, 2005
Posts: 178
Originally posted by Michael Raymond Jr.:


yeah, framename is the ID of the DIV tag righ? does it have to be the NAME attribute? like, <div name="framename"..? I have it as <div id="framename"...which works will all my other code.


god dang, i tried every possibility known to man, or so i thought. i changed the iframe to include the NAME attribute, and now the target in FORM is working. guess i answered me own question ;-)

this only works for printing the result of the servlet to the screen instead of to a file and loading that file which is what i'm doing. hwoever, i did not want it that way originally and only did this to remedy the servlet results not appearing in the destination i wanted. thanks for the responses anyhow, at least they got my wheels turning.

conclusion:
the target="destFrame" in the FORM was not working with

<div id="framename"></div>

but did with

<div name="framename"></div>

this was with both IE and FF.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61657
    
  67

You cannot target ids, only names.
Michael Raymond Jr.
Ranch Hand

Joined: May 16, 2005
Posts: 178
Originally posted by Bear Bibeault:
You cannot target ids, only names.


yeah, it appears that way. wish i knew that 4 hours ago...

ID works with JS getElementById() and CSS, but not html target. they should change that.

is it considered a good practice to use both NAME and ID and set them to the same value?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about forms