View Full Version : Empty GET variables (PHP + JS)

07-12-2007, 08:19 PM

I have a search form that uses get variables, and will not use post variables, and I have some optional options that still pass empty variables. The search form is located at http://www.rentalnook.com/search.php. If you click advanced options you will see the drop downs that I have, and I want to make it so that I can unset the get variables when the form is submitted. I know this is possible because I already have a PHP function that a.) takes all the GET variables and echos them (for links) and b.) unsets any GET variable. The problem is the JavaScript part, because there isn't a Javascript equivalent to this function because of the necessary server-side functions and variables. I was thinking that I make a javascript function that checked blank values for those drop down boxes and either a.) manually "submitted" the form, by taking every non-blank variable and just do a location.href='results.php?firstvar=1...' or b.) call that function before the submit button somehow. But I would need to take variables from Javascript to PHP easily. That is what I feel would be the easiest, and most efficient way. aThanks for any help.

07-13-2007, 01:00 PM
I don't understand what you are trying to achieve, is it some kind of form validation?

There is an "onsubmit" attribute for a form that is used to call a javascript function. This function can do anything you like and then decide whether of not to actually send the form or not. Is this what you're after?