I did a search as I had hoped this has been dealt with by someone before me.

I'm trying to take a search form on a website and ONLY pass fields or values for fields that are actually selected or used.

What I mean is this. The search form has 16 fields and regardless of how many fields the user actually uses, the string or "GET" url includes ALL fields. I'd like to make several fields excluded unless a user has selected that criteria.

When a person searches for just MLS # for instance, things like Square Foot, Price, City, Zip, and all other fields are pointless to process which causes substantial burden on the system because there are 57,000 listings.

JavaScript will work, my question is are there examples anywhere?

Recommended Answers

All 8 Replies

The only way to exclude fields from being passed with the querystring is to mark them as disabled. Disabled form data is not submitted. How to achieve this would be your call.

You can on form submit call a function which would disable all the fields whose trimmed value is a blank string.

I do have it working but there is a strange issue with FireFox. You can see the example and the code here. http://www.elpasohomepage.com/listings/hidefields.html

If you select for instance ONLY price range and leave all others untouched you will notice it passes only fields with values. I believe I have image only set as a default so that will always pass on this search.

Does anyone have any idea why the code acts the way it does in FireFox?

~ Jared

Can you describe the issu or make screenshot of it because I tried various things and always got results. Or you solved that problem?

Yes the issue is this, when I submit the form once it works fine, but when I go back to the form in FireFox it leaves the text fields inactive so I could not add a value to them if I wanted to.

The only reason I wanted to bother with this is the size of the search form I did during the integration of the new redesign of Condolux. You can see the form there at http://www.condolux.net/myrtle-beach-listings/ That site (joomla, wordpress openrealty) works fine except when we have a spank of traffic it can literally crawl and its because of the size of the search forms. There is no need to query fields with "NULL" values so we use this script but it is causing me a headache in FireFox.

Any help is greatly appreciated.


~ Jared

*bump back to attention*

you may need to trigger an onload event to reverse them.

Yeah I'm not sure but I tried the following with no success.

<script type="text/javascript">
function noBack(){window.history.forward();}
</script>

<body onload="noBack();" onpageshow="if(event.persisted)noBack();" onunload="">

And I tried
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">

I'm not sure its a caching issue but I'll keep looking.

I actually had in mind a function that, every time the user goes to that page, will loop through all of the form elements and if disabled will enable them.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.