Ive created a form with one text field that will be used to search an engine for properties. I've set up javascript so that depending on what is entered, the form then knows what the user is searching by (zip, city, or ID) and then the corresponding value.
The search engine takes strict parameters of (example) KeyField="City" and City="Atlanta"
Here is what I have so far:
I've tested bits of the code, and the problem lies in the part where I write the hidden field. If I dont have the brackets <>, the script seems to write fine.Code:<form id="propSearch" name="propSearch" method="post" action="http://atlantapremiererealestate.listingware.com/search/searchresults.cfm"> <input name="shortCut" type="text" id="shortCut"/> <script type="text/javascript"> <!-- var textValue = document.propSearch.shortCut.value; var Keyfield = ""; if (isNaN(textValue)) { KeyField = "City"; } else { if(textValue.length == 5) { KeyField = "PostalCode"; } else { KeyField = "ListingID"; } } var theField = "<input type=\"hidden\" name=\"KeyField\" value=\"" + KeyField + "\"/>"; document.write(theField); var theValue = "<input type=\"hidden\" name=\"" + KeyField + "\" value=\"" + textValue + "\"/>"; document.write(theValue); //--> </script> <input type="submit" name="Submit" value="Go!"/> </form><p>Enter City, 5 digit Zip, or MLS ID#</p>
Does anyone know what I'm doing wrong and how I can change this?
It's important that I use the post form method with hidden fields rather than create a strURL.



Reply With Quote

Bookmarks