PDA

View Full Version : Holding client entered form value on reloaded search page


Beanie Man
04-27-2007, 02:38 AM
Hi all,
I have a frustrating problem with a search page that wont hold the values entered by the user in two dynamic drop down boxes when the search is refreshed. Ive managed to hold the values of the non dynamically generated drop boxes with a combination of asp and JavaScript.

If you visit my web site http://www.wheretobuycarsfrom.com/buyacar.asp and search for a car the results page will fail to keep the value of the Make and Model you searched for.

The options for these two form fields are generated by the file http://www.wheretobuycarsfrom.com/list.js and the function fillCatagory() is called by a body onload attribute.

The form that generates the search has the dynamic selection boxes as follows with some asp to gather the values of the fields.(ive left out the other form fields so as not to clutter things up too much)

<select class="fieldmake" NAME="Make" onChange="SelectsubCat();"
<%
if request.querystring("Make") <> "" then response.write " value = """ & request.querystring("Make") & """"
%>
>
<Option>Any Make</option>
</select>
</td>
<td class="formtablecell">
<select class="fieldmodel" id="Model" NAME="Model">
<Option value="Any Model">Any Model</option>
</select>


Then at the foot of the search results page i have the following to fill the fields;

<script type="text/javascript">
drop_list.Make.value = "<% = request.querystring("Make") %>"
drop_list.Make.value = "<% = request.querystring("Model") %>"
drop_list.D3.value = "<% = request.querystring("D3") %>"
drop_list.D1.value = "<% = request.querystring("D1") %>"
drop_list.D2.value = "<% = request.querystring("D2") %>"
drop_list.search_postcode.value = "<% = request.querystring("search_postcode") %>"
</script>

This hold the values of D3,D2,D1 and search_postcode fine but wont hold the Make and Model values.

This makes searching a pain and would be very gratefull if someone could help me fix this quite major problem.

Many many thanks in advance.:thumbsup:

david_kw
04-27-2007, 07:29 AM
I think your problem is a typo. You had

drop_list.Make.value = "<% = request.querystring("Make") %>"
drop_list.Make.value = "<% = request.querystring("Model") %>"

and it should be


drop_list.Make.value = "Honda"
drop_list.Model.value = "Civic"

// also in this function I saw the same problem
function formValidator(){
// Make quick references to our fields
var Make = document.getElementById('Make');
var Model = document.getElementById('Model');
.
.
.

Beanie Man
04-27-2007, 12:50 PM
Hey David,
Thanks for pointing out the typo's I've changed them both and crossed my fingers but unfortunately with no joy.
What is happening now is in IE the Make box still shows the default value when a new search is entered and the Model box is empty!!

In Opera both Make and Model fields are empty on refresh. In Firefox and Netscape none of the form fields retain the entered values even the ones that work (price, distance, postcode) in Opera and IE!!! Before i posted this thread i had not checked this problem in FF and NS so maybe this will give a better idea about what is going on!!!

Thanks again for your help David

john86
09-18-2009, 11:29 AM
Thanks for sharing this gr8 knowledge about typo i think my site has same coding problem but i can solve that.
Semi trucks (http://www.oilstruck.com) in USA