GET and POST mixed up ??

W

Ward

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;
}
 
W

Ward

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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,201
Latest member
KourtneyBe

Latest Threads

Top