Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > submit form data to a new window failed using HTTP POST

Reply
Thread Tools

submit form data to a new window failed using HTTP POST

 
 
Matt
Guest
Posts: n/a
 
      08-23-2004
The following program submit a FORM DATA to a new window using HTTP
POST,
and postprocess.jsp couldn't get the form data. If I do in GET method
and pass by query string in windowURL, then it works. But I need HTTP
POST method, and I cannot use target="_blank" because I need to
control the new window's properties (disable the scrollbars, menubars,
etc...)

Are there any workarounds?

<html>
<script type="text/javascript">
function checkAndSubmitForm(theForm)
{
var windowURL = theForm.action;
window.open(windowURL, "newWin",
"scrollbars=0,menubar=0,toolbar=0,location=0,statu s=0");
}
</script>

<body>
<FORM NAME="formname" method="POST" action="postprocess.jsp">
<P><input type=text" name="username"/>
<P><input type="button" name="submitBtn" value="Submit Form"
onClick="checkAndSubmitForm(document.formname)">
</FORM>
</body>
</html>

postprocess.jsp is just one line statement to get the form data
<%= Request.Form() %>


any ideas? please help!! thanks!!
 
Reply With Quote
 
 
 
 
Adrienne
Guest
Posts: n/a
 
      08-23-2004
Gazing into my crystal ball I observed http://www.velocityreviews.com/forums/(E-Mail Removed) (Matt)
writing in news:(E-Mail Removed) om:

> The following program submit a FORM DATA to a new window using HTTP
> POST,
> and postprocess.jsp couldn't get the form data. If I do in GET method
> and pass by query string in windowURL, then it works. But I need HTTP
> POST method, and I cannot use target="_blank" because I need to
> control the new window's properties (disable the scrollbars, menubars,
> etc...)


Why do you want to do that? Please do not mess with my browser. I hate
what you want to do.

>
> Are there any workarounds?


Yes, submit to another page, sure, but just use the same window.

>
><html>
><script type="text/javascript">
> function checkAndSubmitForm(theForm)
> {
> var windowURL = theForm.action;
> window.open(windowURL, "newWin",
> "scrollbars=0,menubar=0,toolbar=0,location=0,statu s=0");
> }
></script>


Where is your HEAD element?

>
><body>
><FORM NAME="formname" method="POST" action="postprocess.jsp">


IIRC you must define the name of the form that is going to be used by your
javascript here, so <form name="theform" method="post"
action="postprocess.jsp">

><P><input type=text" name="username"/>
><P><input type="button" name="submitBtn" value="Submit Form"
> onClick="checkAndSubmitForm(document.formname)"> </FORM> </body> </html>


Your javascript is looking for the value of the action attribute of the
form element. It will not know what to do because it is expecting
"theform" and the value that is being passed is "formname".

>
> postprocess.jsp is just one line statement to get the form data
><%= Request.Form() %>
>
>
> any ideas? please help!! thanks!!
>


Get rid of the idea of opening a window without menu, scrollbar, etc. Also
think about visitors without javascript who will not get your silly window
anyway.

--
Adrienne Boswell
Please respond to the group so others can share

 
Reply With Quote
 
 
 
 
Jukka K. Korpela
Guest
Posts: n/a
 
      08-23-2004
(E-Mail Removed) (Matt) wrote:

> The following program submit a FORM DATA to a new window


Well, it doesn't, but presumably you would like it to work that way.

The best advice is: think twice before wanting that, and if the result is
that you still want it, think again.

> I cannot use target="_blank" because I need to
>> control the new window's properties (disable the scrollbars, menubars,
>> etc...)


The second best advice is to use a target="..." attribute in a <form>
tag, with a value that does not otherwise appear as window or frame name
in your design, and use JavaScript to _only_ open a new window with that
name and with the desired properties, leaving its content empty (it will
be filled by your form handler, of course). For details & examples see
http://www.cs.tut.fi/~jkorpela/forms...pt.html#window

> <input type="button" name="submitBtn" value="Submit Form"
> onClick="checkAndSubmitForm(document.formname)">


That way the form would not work at all when JavaScript is disabled or
filtered out, and the user would see this only after filling out all the
data and trying to click on the button. So use input type="submit".

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html


 
Reply With Quote
 
SpaceGirl
Guest
Posts: n/a
 
      08-23-2004
Adrienne wrote:

> Gazing into my crystal ball I observed (E-Mail Removed) (Matt)
> writing in news:(E-Mail Removed) om:
>
>
>>The following program submit a FORM DATA to a new window using HTTP
>>POST,
>>and postprocess.jsp couldn't get the form data. If I do in GET method
>>and pass by query string in windowURL, then it works. But I need HTTP
>>POST method, and I cannot use target="_blank" because I need to
>>control the new window's properties (disable the scrollbars, menubars,
>>etc...)

>
>
> Why do you want to do that? Please do not mess with my browser. I hate
> what you want to do.
>
>
>>Are there any workarounds?

>
>
> Yes, submit to another page, sure, but just use the same window.
>
>
>><html>
>><script type="text/javascript">
>>function checkAndSubmitForm(theForm)
>>{
>> var windowURL = theForm.action;
>> window.open(windowURL, "newWin",
>>"scrollbars=0,menubar=0,toolbar=0,location=0,sta tus=0");
>>}
>></script>

>
>
> Where is your HEAD element?
>
>
>><body>
>><FORM NAME="formname" method="POST" action="postprocess.jsp">

>
>
> IIRC you must define the name of the form that is going to be used by your
> javascript here, so <form name="theform" method="post"
> action="postprocess.jsp">
>
>><P><input type=text" name="username"/>
>><P><input type="button" name="submitBtn" value="Submit Form"
>>onClick="checkAndSubmitForm(document.formname) "> </FORM> </body> </html>

>
>
> Your javascript is looking for the value of the action attribute of the
> form element. It will not know what to do because it is expecting
> "theform" and the value that is being passed is "formname".
>
>
>>postprocess.jsp is just one line statement to get the form data
>><%= Request.Form() %>
>>
>>
>>any ideas? please help!! thanks!!
>>

>
>
> Get rid of the idea of opening a window without menu, scrollbar, etc. Also
> think about visitors without javascript who will not get your silly window
> anyway.
>


Too generic. What if the page is on an Intranet, or part of an in-house
application, or part of some extranet application? Then, just like any
other software application, it'd be quite reasonable ask for things like
this to be enabled...

One of the projects I'm working on right now is a web-based application.
It uses some nasty scripting, but that's fine as it's part of the
specification of the application. It works in FF and IE, but it REQUIRES
scripting, and REQUIRES degrees of window control. It says so on the
back of the box the application ships in

--


x theSpaceGirl (miranda)

# lead designer @ http://www.dhnewmedia.com #
# remove NO SPAM to email, or use form on website #
 
Reply With Quote
 
Juhani M?ntt?ri
Guest
Posts: n/a
 
      08-23-2004
Adrienne <(E-Mail Removed)> wrote in message > >
> >
> > any ideas? please help!! thanks!!
> >

>
> Get rid of the idea of opening a window without menu, scrollbar, etc. Also
> think about visitors without javascript who will not get your silly window
> anyway.


I fully agree on that!

But you can do that by using <form action="blah.jsp" target="_blank">,
but consider that seriously, 'cause opening pop-ups will get quite
annoying. Plus that most of the time I use a browser it has pop-ups
blocked, and so do many many other users as well.
 
Reply With Quote
 
Robert Frost-Bridges
Guest
Posts: n/a
 
      08-23-2004
Adrienne wrote:

[snip]

>><html>
>><script type="text/javascript">
>> function checkAndSubmitForm(theForm)
>> {
>> var windowURL = theForm.action;
>> window.open(windowURL, "newWin",
>> "scrollbars=0,menubar=0,toolbar=0,location=0,statu s=0");
>> }
>></script>

>
> Where is your HEAD element?


It's optional:
http://www.w3.org/TR/1998/REC-html40...html#edef-HEAD

--
Robert
http://brightonfixedodds.net
 
Reply With Quote
 
Mark Parnell
Guest
Posts: n/a
 
      08-23-2004
On Mon, 23 Aug 2004 10:00:44 +0100, SpaceGirl
<(E-Mail Removed)> declared in alt.html:

> Too generic. What if the page is on an Intranet, or part of an in-house
> application, or part of some extranet application?


Then the OP should have said that, as it is assumed that the question is
in a www context, unless otherwise specified.

--
Mark Parnell
http://www.clarkecomputers.com.au
"Never drink rum&coke whilst reading usenet" - rf 2004
 
Reply With Quote
 
Isofarro
Guest
Posts: n/a
 
      08-27-2004
Matt wrote:

> postprocess.jsp is just one line statement to get the form data
> <%= Request.Form() %>


JSP? Unless you have defined and imported a static class called Request, or
instantiated an object with the reference "Request", along with an oddly
named method called "Form()", then the above isn't going to work.

The form data in a JSP page is retrieved using the getParameter() method of
the request object. So a field called "clientName" is retrieved using the
expression <%= request.getParameter("clientName") %>




--
Isofarro.
FAQ: http://www.html-faq.com/
Recommended Hosting: http://www.affordablehost.com/
isolani: http://www.isolani.co.uk/blog/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
submit form data to a new window failed using HTTP POST Matt Java 4 09-14-2006 04:13 PM
submit the form data to the popup window without a submit button jrefactors@hotmail.com Javascript 2 01-01-2005 06:07 AM
submit the form data to the popup window without a submit button jrefactors@hotmail.com HTML 2 01-01-2005 06:07 AM
submit form data to a new window failed using HTTP POST Matt Javascript 1 08-23-2004 12:25 PM
submit form data to a new window failed using HTTP POST Matt ASP General 1 08-23-2004 10:48 AM



Advertisments