Hi, all
When I do as the following, it becomes a GET action to the the server. How
do I make it as a POST action? That means I don't want the string after "?"
show on URL bar and, to the server, it can follow POST function to get the
data passed in. Thank you very much!
window.open("../../Server.php?"+xsValue, "", zNONHTML_STYLE);
Jack 18 1684
"q2005" wrote When I do as the following, it becomes a GET action to the the server.
How do I make it as a POST action? That means I don't want the string after
"?" show on URL bar and, to the server, it can follow POST function to get
the data passed in. Thank you very much!
window.open("../../Server.php?"+xsValue, "", zNONHTML_STYLE);
This is a GET request, yes, but only if javascript is available. Without
javascript it is nothing.
If you want to POST something, there is no around using a form. If the
reliance on javascript is not a problem (but it usually is), this form can
be built dynamically:
var f=document.createElement('form');
document.body.appendChild(f);
f.action='../../Server.php';
f.method='post';
var i=document.createElement('input');
f.appendChild(i);
i.type='hidden';
i.name='somename';
i.value=xsValue;
f.submit();
HTH
--
Ivo
Thanks, Ivo. It's so helpful. By the way, after summit, how do I delete the
form object? Thanks again!
Jack This is a GET request, yes, but only if javascript is available. Without javascript it is nothing. If you want to POST something, there is no around using a form. If the reliance on javascript is not a problem (but it usually is), this form can be built dynamically: var f=document.createElement('form'); document.body.appendChild(f); f.action='../../Server.php'; f.method='post'; var i=document.createElement('input'); f.appendChild(i); i.type='hidden'; i.name='somename'; i.value=xsValue; f.submit();
HTH -- Ivo
"q2005" wrote This is a GET request, yes, but only if javascript is available. Without javascript it is nothing. If you want to POST something, there is no around using a form. If the reliance on javascript is not a problem (but it usually is), this form
can be built dynamically: var f=document.createElement('form'); document.body.appendChild(f); f.action='../../Server.php'; f.method='post'; var i=document.createElement('input'); f.appendChild(i); i.type='hidden'; i.name='somename'; i.value=xsValue; f.submit();
Thanks, Ivo. It's so helpful. By the way, after summit, how do I delete
the form object? Thanks again!
You don't. The form is submitted, so the whole page is 'deleted' as the
server responds with a brand new page. Note that the example code provided
does not test for features before using them. Include
if(document.createElement) {...} and stuff like that before using it in the
real world. Also, try to avoid relying on javascript. If you can do it with
an ordinary form, and it sounds like you can, then do.
HTH
--
Ivo
Thanks a lot, Ivo.
How do I let it be opened in a separate window after submmit?
Jack
"q2005" aka Jack wrote How do I let it be opened in a separate window after submmit?
In standard HTML, you can add a target attribute to the form opening tag and
it will behave just like the target attribute of <a> tags:
<form action="..." method="..." target="_blank">
Amazing, isn't it?
In Javascript, to get the same result, you could add this line to the code
we discussed earlier:
f.target='_blank';
--
Ivo
Thanks very much, Ivo. It works!
Jack In standard HTML, you can add a target attribute to the form opening tag
and it will behave just like the target attribute of <a> tags:
<form action="..." method="..." target="_blank">
Amazing, isn't it? In Javascript, to get the same result, you could add this line to the code we discussed earlier:
f.target='_blank';
-- Ivo
Hi, Ivo
I tried this script and found "i.type='hidden';" won't work. I changed to
"i.type='text';" , it works. But it will show on the original page.
Jack
"Ivo" <no@thank.you> wrote in message
news:41***********************@news.wanadoo.nl... "q2005" wrote When I do as the following, it becomes a GET action to the the server. How do I make it as a POST action? That means I don't want the string after "?" show on URL bar and, to the server, it can follow POST function to get the data passed in. Thank you very much!
window.open("../../Server.php?"+xsValue, "", zNONHTML_STYLE);
This is a GET request, yes, but only if javascript is available. Without javascript it is nothing. If you want to POST something, there is no around using a form. If the reliance on javascript is not a problem (but it usually is), this form can be built dynamically: var f=document.createElement('form'); document.body.appendChild(f); f.action='../../Server.php'; f.method='post'; var i=document.createElement('input'); f.appendChild(i); i.type='hidden'; i.name='somename'; i.value=xsValue; f.submit();
HTH -- Ivo
On Tue, 16 Nov 2004 20:11:56 +1000, q2005 <q2***@tpg.com.au> wrote: I tried this script and found "i.type='hidden';" won't work.
I assume you mean with IE?
According to Microsoft, the type attribute "is read[-many]/write-once, but
only when an input element is created with the createElement method and
before it is added to the document."
To be safe, the appendChild (or similar, like insertBefore) should be the
very last operation with a dynamically-created element. Set all of the
properties, and only then should said element be added.
I changed to "i.type='text';" , it works.
Actually, I doubt that. The assignment will still probably fail, but
because text is the default type, it appears as though it succeeded.
[snip]
Mike
Please don't top-post.
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Thanks, Michael. I tried this script and found "i.type='hidden';" won't work. I assume you mean with IE?
Yes, I mean with IE. According to Microsoft, the type attribute "is read[-many]/write-once, but only when an input element is created with the createElement method and before it is added to the document."
To be safe, the appendChild (or similar, like insertBefore) should be the very last operation with a dynamically-created element. Set all of the properties, and only then should said element be added.
After put the appendChild() at the very last, there is no more error!
Jack
"Michael Winter" <M.******@blueyonder.co.invalid> wrote in message news:<opshjy49nqx13kvk@atlantis>... On Tue, 16 Nov 2004 20:11:56 +1000, q2005 <q2***@tpg.com.au> wrote:
I tried this script and found "i.type='hidden';" won't work. I assume you mean with IE?
According to Microsoft, the type attribute "is read[-many]/write-once, but only when an input element is created with the createElement method and before it is added to the document."
To be safe, the appendChild (or similar, like insertBefore) should be the very last operation with a dynamically-created element. Set all of the properties, and only then should said element be added.
I changed to "i.type='text';" , it works.
Actually, I doubt that. The assignment will still probably fail, but because text is the default type, it appears as though it succeeded.
[snip]
Mike
Please don't top-post.
"Ivo" wrote:
If you want to POST something, there is no around using a form.
Might want to read this: http://developer.apple.com/internet/...mlhttpreq.html
Also, the best way to handle the opening of the form action in a new
window is by 1) setting HTML form target to a specific name string and
2) calling a function onsubmit which opens a configured window,
setting its name (2nd argument to open()) to the target name. Might as
well get the window you want.
Thanks, RobB.
Can you give me an example code about "the best way to handle the opening of
the form action in a new window". Thank you very much!
Jack
"RobB" <fe******@hotmail.com> wrote in message
news:ab**************************@posting.google.c om... "Michael Winter" <M.******@blueyonder.co.invalid> wrote in message
news:<opshjy49nqx13kvk@atlantis>... On Tue, 16 Nov 2004 20:11:56 +1000, q2005 <q2***@tpg.com.au> wrote:
I tried this script and found "i.type='hidden';" won't work.
I assume you mean with IE?
According to Microsoft, the type attribute "is read[-many]/write-once,
but only when an input element is created with the createElement method and before it is added to the document."
To be safe, the appendChild (or similar, like insertBefore) should be
the very last operation with a dynamically-created element. Set all of the properties, and only then should said element be added.
I changed to "i.type='text';" , it works.
Actually, I doubt that. The assignment will still probably fail, but because text is the default type, it appears as though it succeeded.
[snip]
Mike
Please don't top-post.
"Ivo" wrote:
If you want to POST something, there is no around using a form.
Might want to read this: http://developer.apple.com/internet/...mlhttpreq.html
Also, the best way to handle the opening of the form action in a new window is by 1) setting HTML form target to a specific name string and 2) calling a function onsubmit which opens a configured window, setting its name (2nd argument to open()) to the target name. Might as well get the window you want.
On Thu, 18 Nov 2004 00:48:30 +1000, q2005 <q2***@tpg.com.au> wrote: Can you give me an example code about "the best way to handle the opening of the form action in a new window". Thank you very much!
It's in the FAQ. The usual link is <URL:http://jibbering.com/faq/>,
however I can't access it at the moment. In the meantime, you can use an
out-of-date copy, courtesy of the Wayback Machine
(<URL:http://www.archive.org/web/web.php>):
<URL:http://web.archive.org/web/20040202174454/http://www.jibbering.com/faq/>
[snip]
Mike
Don't top-post!
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
"Michael Winter" <M.******@blueyonder.co.invalid> wrote in message news:<opshl6oenqx13kvk@atlantis>... On Thu, 18 Nov 2004 00:48:30 +1000, q2005 <q2***@tpg.com.au> wrote:
Can you give me an example code about "the best way to handle the opening of the form action in a new window". Thank you very much!
It's in the FAQ. The usual link is <URL:http://jibbering.com/faq/>, however I can't access it at the moment. In the meantime, you can use an out-of-date copy, courtesy of the Wayback Machine (<URL:http://www.archive.org/web/web.php>):
<URL:http://web.archive.org/web/20040202174454/http://www.jibbering.com/faq/>
[snip]
Mike
Don't top-post!
Dug this out of the vault, hope it helps. Some bits are demo-only.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www/w3/org/TR/xhtml1">
<head>
<title>untitled</title>
<script type="text/javascript">
//<![CDATA[
function dummy(v)
{
return '<h4>' + v + '</h4>';
}
function handle_submit(f)
{
if (document.getElementById('w').checked)
{
f.target = 'formpop';
f.action = 'javascript :opener.dummy(opener.document.forms[0].foo.value)';
//demo only
var w = 300;
var h = 180;
var l = (screen.availWidth - w) * .5;
var t = (screen.availHeight - h) * .5;
var features = 'width='+w+',height='+h+',left='+l+',top='+t+',sta tus,scrollbars,resizable';
formpop = open('about :blank', 'formpop', features);
formpop.focus();
return true;
}
else
{
f.target = '_self';
f.action = 'javascript :dummy(document.forms[0].foo.value)'; //ditto
}
}
// ]]>
</script>
</head>
<body>
<form action="javascript :dummy(document.forms[0].foo.value)"
onsubmit="return handle_submit(this)">
<input id="w" type="checkbox" /> open in new window?<br /><br />
<input type="text" name="foo" value="...enter something here" />
<input type="submit" value="done" />
</form>
</body>
</html>
Thanks RobB.
On this example, when open in a new window, sometimes it won't work. The IE
browser said "this page can not displayed". The most times, it works.
questions:
1. Why on open new window needs to return true while on _self doesn't need?
2. Since on handle_submit(), it will change the action, is the "action=" in
the form a dummy one? Or it should have?
3. How can the action can be executed either on the new page or the original
page? Does it depend on target?
Jack <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www/w3/org/TR/xhtml1"> <head> <title>untitled</title> <script type="text/javascript"> //<![CDATA[
function dummy(v) { return '<h4>' + v + '</h4>'; }
function handle_submit(f) { if (document.getElementById('w').checked) { f.target = 'formpop'; f.action = 'javascript:opener.dummy(opener.document.forms[0].foo.value)'; //demo only var w = 300; var h = 180; var l = (screen.availWidth - w) * .5; var t = (screen.availHeight - h) * .5; var features =
'width='+w+',height='+h+',left='+l+',top='+t+',sta tus,scrollbars,resizable'; formpop = open('about:blank', 'formpop', features); formpop.focus(); return true; } else { f.target = '_self'; f.action = 'javascript:dummy(document.forms[0].foo.value)'; //ditto } }
// ]]> </script> </head> <body> <form action="javascript:dummy(document.forms[0].foo.value)" onsubmit="return handle_submit(this)"> <input id="w" type="checkbox" /> open in new window?<br /><br /> <input type="text" name="foo" value="...enter something here" /> <input type="submit" value="done" /> </form> </body> </html>
On Thu, 18 Nov 2004 16:49:14 +1000, q2005 <q2***@tpg.com.au> wrote:
[snip] 1. Why on open new window needs to return true while on _self doesn't need?
Neither needs to return true, so don't worry about it.
2. Since on handle_submit(), it will change the action, is the "action=" in the form a dummy one? Or it should have?
I should certainly hope it's only a dummy. Making a form submission
dependant upon Javascript is moronic.
3. How can the action can be executed either on the new page or the original page? Does it depend on target?
Not sure what you're asking there.
Anyway, the answer to your previous question is a simple one. As I said,
look at the FAQ (<URL:http://jibbering.com/faq/>). The answer is there.
[snip]
Mike
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
"q2005" <q2***@tpg.com.au> wrote in message news:<41******@dnews.tpgi.com.au>... Thanks RobB. On this example, when open in a new window, sometimes it won't work. The IE browser said "this page can not displayed". The most times, it works. questions: 1. Why on open new window needs to return true while on _self doesn't need? 2. Since on handle_submit(), it will change the action, is the "action=" in the form a dummy one? Or it should have? 3. How can the action can be executed either on the new page or the original page? Does it depend on target?
Jack
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www/w3/org/TR/xhtml1"> <head> <title>untitled</title> <script type="text/javascript"> //<![CDATA[
function dummy(v) { return '<h4>' + v + '</h4>'; }
function handle_submit(f) { if (document.getElementById('w').checked) { f.target = 'formpop'; f.action = 'javascript:opener.dummy(opener.document.forms[0].foo.value)'; //demo only var w = 300; var h = 180; var l = (screen.availWidth - w) * .5; var t = (screen.availHeight - h) * .5; var features = 'width='+w+',height='+h+',left='+l+',top='+t+',sta tus,scrollbars,resizable'; formpop = open('about:blank', 'formpop', features); formpop.focus(); return true; } else { f.target = '_self'; f.action = 'javascript:dummy(document.forms[0].foo.value)'; //ditto } }
// ]]> </script> </head> <body> <form action="javascript:dummy(document.forms[0].foo.value)" onsubmit="return handle_submit(this)"> <input id="w" type="checkbox" /> open in new window?<br /><br /> <input type="text" name="foo" value="...enter something here" /> <input type="submit" value="done" /> </form> </body> </html>
1. Why on open new window needs to return true while on _self doesn't need?
It's not specifically necessary for either, as returning anything but
false will have no effect. Should have moved that to just before the
closing bracket, but it was trivial so I missed it.
2. Since on handle_submit(), it will change the action, is the "action=" in
the form a dummy one? Or it should have?
Yes. btw DEMO ONLY means 'remove this for real-world use'. Just wanted
to avoid posting a sample form page.
3. How can the action can be executed either on the new page or the original
page? Does it depend on target?
You'll need to try that one again.
function handle_submit(f)
{
if (document.getElementById('w').checked)
{
f.target = 'formpop';
var w = 300;
var h = 180;
var l = (screen.availWidth - w) * .5;
var t = (screen.availHeight - h) * .5;
var features = 'width='+w+',height='+h+',left='+l+',top='+t+',sta tus,scrollbars,resizable';
formpop = open('about :blank', 'formpop', features);
formpop.focus();
}
else f.target = '_self';
return true;
}
// ]]>
</script>
</head>
<body>
<form action="[whatever]"
onsubmit="return handle_submit(this)">
"Ivo" <no@thank.you> wrote in message news:<41***********************@news.wanadoo.nl>.. . s, Ivo. It's so helpful. By the way, after summit, how do I delete the form object? Thanks again!
You don't. The form is submitted, so the whole page is 'deleted' as the server responds with a brand new page. Note that the example code provided does not test for features before using them. Include if(document.createElement) {...} and stuff like that before using it in the real world. Also, try to avoid relying on javascript. If you can do it with an ordinary form, and it sounds like you can, then do.
If document.createElement() is not supported, what else should we test
for? Or appendChild? I assume this is GECKO DOM? The alternative would
be IE's DOM? Or vice versa? Are there mostly 2 DOM's out there to test
for, or more?
Is it possible to submit the forms without submitting the page? If
possible that might be a nice way to do an interface for a chat
software running PHP and MySql in the background.
On 18 Nov 2004 12:56:22 -0800, lawrence <lk******@geocities.com> wrote:
Just briefly...
[snip] If document.createElement() is not supported, what else should we test for? Or appendChild? I assume this is GECKO DOM?
No, it's the W3C - the standardised - DOM. Microsoft just doesn't support
it too well.
The alternative would be IE's DOM?
Pretty much. However, IE does support those methods you mentioned. There
aren't any alternatives as far as I know.
[snip]
Mike
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: perseus |
last post by:
I think that everyone who told me that my question is irrelevant,
in particular Mr. David White,
is being absolutely ridiculous. Obviously, most of you up here
behave like the owners of the C++...
|
by: sbayeta |
last post by:
Hi,
I'd like to know who is responsible of memory recycling and
defragmentation in a C/C++ program, assuming all the memory
allocation/deallocation is done using malloc/free or new/delete.
...
|
by: designconcepts |
last post by:
bo'jour, bo'jour,
So I have question to present to the forum about OOD. This is a Csharp
forum, but C# is the lang of choice and the question is an exercise based on
some comments by the chief...
|
by: BM |
last post by:
Hello,
Ok, Im new to using ASP.NET and IIS so im not sure how or where to post this
question but here goes:
I am running IIS 5.1 on WinXP. I need to process http POST messages sent
from...
|
by: glenn |
last post by:
I am use to programming in php and the way session and post vars are past
from fields on one page through to the post page automatically where I can
get to their values easily to write to a...
|
by: Rider |
last post by:
Hi, simple(?) question about asp.net configuration..
I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm
first start application the follow message shown.
=========
Server...
|
by: MP |
last post by:
Greets,
context: vb6/ado/.mdb/jet 4.0 (no access)/sql
beginning learner, first database, planning stages
(I think the underlying question here is whether to normalize or not to
normalize this...
|
by: Jeff |
last post by:
In the function below, can size ever be 0 (zero)?
char *clc_strdup(const char * CLC_RESTRICT s)
{
size_t size;
char *p;
clc_assert_not_null(clc_strdup, s);
size = strlen(s) + 1;
|
by: stwebmail |
last post by:
If you are dealing with one PCI card, is there a way (from within a
dll) to find out which PCI slot that card is inhabiting (1 or 2 or 6,
etc.)? It doesn't matter if the solution is MFC, or...
|
by: TamusJRoyce |
last post by:
I know it's bad to cross post, but I'm not sure if this is a VB or a .Net question, since I'm a C++ programmer primarily. My code I'm working on is VB .Net, and I'm not familiar with the Framework...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |