Click to See Complete Forum and Search --> : Parameter in - parameter out


brutfood
02-25-2003, 04:58 AM
What I want to do is really simple, I just can't get it right. It's a homer simpson day.

I have a form that I'm sending up to php, post method. I want to include in this form, an invisible field - a parameter that was passed into the HTML containing the form.

myform.html?myparameter=avalue

(doesn't have to be an invisible field - but want the value to be posted anyway when I hit submit).

This is probably really easy, and probably don't even need JavaScript - but I just can't get it.

Also, I would like to know how to access a (?myparameter=avalue) parameter value inside a JavaScript function, even if not applicable to this problem.

gil davis
02-25-2003, 05:46 AM
What you are looking for is the "search" parameter of the "location" object. If you call a page using:

myform.html?myparameter=avalue

then window.location.search will contain:

?myparameter=avalue

Using appropriate string methods, you can separate the variable and it's value.

Dan Drillich
02-25-2003, 12:39 PM
If you use the get method in your form, the hidden field will be passed in the url. Then you can access it as Gil suggested.

pyro
02-25-2003, 12:41 PM
If you are using PHP, why not just use $QUERY_STRING?

brutfood
02-25-2003, 05:37 PM
Thanks gil for window.location.search. I'm surprised there was no method to access individual parameters - which is what I was looking for. But I can just pass ?avalue - and knock off the '?'. Anyway, using this, I'll try to set up my hidden field - Although I'm suprised there was no pure HTML solution to this.

$QUERY_STRING would access the query string of the PHP, not the HTML that passes a form to it. I use the POST method because I am passing a file (.jpg). Won't a hidden field be passed whether I use POST or GET? I suspect I worded my question in a confusing way.

.SWF ->get-> .HTML ->post(.jpg)-> .PHP ->returns-> .HTML containing .SWF

pyro
02-25-2003, 05:49 PM
Originally posted by brutfood
Won't a hidden field be passed whether I use POST or GET?Yes, either way, a hidden form field will be passed.