• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about forms

 
Michael Raymond Jr.
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Michael Raymond Jr.
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't seem to get my code psoted in the CODE tags, so here goes:

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Michael Raymond Jr.
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is this what you did?
<form target="frameName" ....>

Eric
 
Michael Raymond Jr.
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot target ids, only names.
 
Michael Raymond Jr.
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic