• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question about forms

 
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't seem to get my code psoted in the CODE tags, so here goes:

 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You cannot target ids, only names.
 
Michael Raymond Jr.
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Grow your own food... or this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic