Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><em>Edit: I may have misunderstood your question. If you're wondering how to remembering the selected options after submitting it to the server, this answer doesn't cover that.</em></p> <p>When changing between buy and rent, keep tabs on what was selected before the change. When you change back, use this information to set the dropdown's <code>selectedIndex</code> property.</p> <p>Example: </p> <ol> <li>You have selected buy and selected min = 100 and max = 200.</li> <li>You change from buy to sell. Now lastMin = 100 and lastMax = 200</li> <li>You change back to buy. You know that the last values were 100 and 200, so you set the dropdowns' values accordingly</li> </ol> <p>I made a demo of it in practice here: <a href="http://jsfiddle.net/VUBQL/" rel="nofollow">http://jsfiddle.net/VUBQL/</a> . The code is as follows</p> <pre><code>var lastSelectedIndexes = { min: -1, max: -1 }; //The callback function when BuyRent changes function buyRentChanged() { var maxPrice = document.SearchForm.MaxPrice; var minPrice = document.SearchForm.MinPrice; //Save currently selected indexes var selectedIndexes = { min: minPrice.selectedIndex, max: maxPrice.selectedIndex }; var BuyRent = this.value if (BuyRent=='buy') { maxPrice.options[0] = new Option("Price (Max)","150000000"); maxPrice.options[1] = new Option("\u00A3100,000","100000"); maxPrice.options[2] = new Option("\u00A3200,000","200000"); minPrice.options[0] = new Option("Price (Min)","0"); minPrice.options[1] = new Option("\u00A3100,000","100000"); minPrice.options[2] = new Option("\u00A3200,000","200000"); } else if (BuyRent=='rent') { maxPrice.options[0]=new Option ("Price (Max)","9999999"); maxPrice.options[1]=new Option("\u00A3250","250"); maxPrice.options[2]=new Option("\u00A3500","500"); minPrice.options[0]=new Option("Price (Min)","0"); minPrice.options[1]=new Option("\u00A3250","250"); minPrice.options[2]=new Option("\u00A3500","500"); } //Set selected index to the last selected index, if it was set if (lastSelectedIndexes.min !== -1) minPrice.selectedIndex = lastSelectedIndexes.min; if (lastSelectedIndexes.max !== -1) maxPrice.selectedIndex = lastSelectedIndexes.max; //Save the current indexes lastSelectedIndexes.max = selectedIndexes.max; lastSelectedIndexes.min = selectedIndexes.min; } var radioBoxes = document.SearchForm.BuyRent radioBoxes[0].onchange = buyRentChanged; radioBoxes[1].onchange = buyRentChanged; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload