By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,341 Members | 1,726 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,341 IT Pros & Developers. It's quick & easy.

GET and POST mixed up ??

P: n/a
I have a form 'G' with a selectbox and an inputbox.
The selectbox contains 20 usernames.
The inputbox contains a date (=tot). Next to it is a button.

The selectbox uses an onchange event to launch the function jumpoff.
onchange="jumpoff(this, 'gebruiker')";

The inputbox uses an onclick event to invoke the same function.
onclick="jumpoff(document.G.tot,'datum');"

Inside the jumpoff function :
If it is a date then I reorder the dateparts and assign to x.
If it is not I simply assign the value to x.
Notice the alert function : it proves to me that the compounded string is
correct IN BOTH situations, ie I get both

contractsearch.php?usr=gebruiker&geselecteerd=ADR
as well as
contractsearch.php?usr=datum&geselecteerd=20040326

The very same string is used in a location method to call this phpscript.
The phpscript expects the values to arrive using GET.

Here is the problem : it only receives them when the selectbox changes.
If the inputbox/button is used, POST variables arrive in the script.

var_dump proves this :
Using the selectbox, var_dump($_GET) yields as expected
array(2) { ["usr"]=> string(9) "gebruiker" ["geselecteerd"]=> string(3)
"ADR" }

Using the inputbox/button, var_dump($_GET) yields
array(2) { ["tot"]=> string(10) "26/03/2004" ["Submit"]=> string(4)
"Zoek"}. These are POST values.

As I said earlier the alert function gives me this:
contractsearch.php?usr=datum&geselecteerd=20040326

I have no clue.

Thx

Ward
function jumpoff(obj,param) {
var x,y;
if (obj.type=="select-one")
{x=obj.options[obj.selectedIndex].value;}
else
{y=obj.value;
x=y.substr(6,4)+y.substr(3,2)+y.substr(0,2);}
alert ('contractsearch.php?usr='+param+'&geselecteerd='+ x);
parent.frames['main'].location='contractsearch.php?
usr='+param+'&geselecteerd='+x;
}
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Ward <ki************@for.president.com> wrote in
news:Xn**********************************@195.130. 132.70:
I have a form 'G' with a selectbox and an inputbox.
The selectbox contains 20 usernames.
The inputbox contains a date (=tot). Next to it is a button.

The selectbox uses an onchange event to launch the function jumpoff.
onchange="jumpoff(this, 'gebruiker')";

The inputbox uses an onclick event to invoke the same function.
onclick="jumpoff(document.G.tot,'datum');"

Inside the jumpoff function :
If it is a date then I reorder the dateparts and assign to x.
If it is not I simply assign the value to x.
Notice the alert function : it proves to me that the compounded string
is correct IN BOTH situations, ie I get both

contractsearch.php?usr=gebruiker&geselecteerd=ADR
as well as
contractsearch.php?usr=datum&geselecteerd=20040326

The very same string is used in a location method to call this
phpscript. The phpscript expects the values to arrive using GET.

Here is the problem : it only receives them when the selectbox
changes. If the inputbox/button is used, POST variables arrive in the
script.

var_dump proves this :
Using the selectbox, var_dump($_GET) yields as expected
array(2) { ["usr"]=> string(9) "gebruiker" ["geselecteerd"]=>
string(3) "ADR" }

Using the inputbox/button, var_dump($_GET) yields
array(2) { ["tot"]=> string(10) "26/03/2004" ["Submit"]=> string(4)
"Zoek"}. These are POST values.

As I said earlier the alert function gives me this:
contractsearch.php?usr=datum&geselecteerd=20040326

I have no clue.

Thx

Ward
function jumpoff(obj,param) {
var x,y;
if (obj.type=="select-one")
{x=obj.options[obj.selectedIndex].value;}
else
{y=obj.value;
x=y.substr(6,4)+y.substr(3,2)+y.substr(0,2);}
alert ('contractsearch.php?usr='+param+'&geselecteerd='+ x);
parent.frames['main'].location='contractsearch.php?
usr='+param+'&geselecteerd='+x;
}


Still don't know what causes this, but worked around it by modifying the
receiving script so that it anticipates POST data as well.
Everything works now.

The htmlform is actually quite complex, with numerous forms that use
post, get, javascript and "absense of action" techniques to pass data to
other scripts (or itself).
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.