Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3232568
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:10:35+00:00 2026-05-17T17:10:35+00:00

I have a dropdown in my form (the code was provided) and when the

  • 0

I have a dropdown in my form (the code was provided) and when the second option (of2) in the drop down is selected, some form elements change. It all works fine.

What I want to be able to do is change the dropdown to two radio buttons instead.

Having the same form changes take place on selection of the second radio button (with the first being selected primarily on page load, by default).

This is the form code for the dropdown:

<form id="propsearch_res" name="propsearch_res" method="post">
  <select name="sales_rental" id="sales_rental" onChange="onChange(this.form)">
     <option value="S" selected="selected">Properties For Sale</option>
     <option value="L">Properties To Let</option>
  </select>
...  

and this is the current javascript which powers the change (and rest of form):

    <script type="text/javascript">  
  function nongeosearch() {
     document.form1.xstyle.value = "7";
  }
  function onChange(obj) {
    var Current = obj.sales_rental.selectedIndex;
    var n = 1;
  obj.price_low.options.length = 0;
  obj.price_high.options.length = 0;

  if (obj.sales_rental.value == "S")
    {
    setsel(obj,"Any Price","","0");
  setsel(obj,"£30,000","30000",n);n=n+1;
  setsel(obj,"£40,000","40000",n);n=n+1;
  setsel(obj,"£50,000+","",n);n=n+1;
    } else {
     setsel(obj,"Any p/month","","0");
  setsel(obj,"£300","300",n);n=n+1;
  setsel(obj,"£400","400",n);n=n+1;
  setsel(obj,"£500+","",n);n=n+1;
    }    
  }   
  $(document).ready(function() {
     onChange(document.propsearch_res);
  });
  function setsel(obj,val1,val2,n) {
     obj.price_low.options[n] = new Option(val1,val2);
     obj.price_high.options[n] = new Option(val1,val2);
  }
 </script>

This is what I tried with my two radio buttons
(It didnt work, but I think thats because something needs tweaking in the javascript :S)

<input type="radio" id="sales_rental" name="sales_rental" value="S" />
<input type="radio" id="sales_rental" name="sales_rental" value="L" onChange="onChange(this.form)" />

I have also tried:

<input ...onClick="onChange(this.form)" />

…without success.

Any help would be very much appreciated!

Thank you for reading

====
Still no joy… my radio buttons are now like this:

<input type="radio" name="sales_rental" checked value="S" />
<input type="radio" name="sales_rental" value="L" />

and the JS with your changes in (hopefully in the right place?):

<script type="text/javascript">  
    function nongeosearch() {
       document.form1.xstyle.value = "7";
    }
    function onChange(obj) {
var n = 1;
obj.price_low.options.length = 0;
obj.price_high.options.length = 0;

if (obj.find("input[name=sales_rental]").val() == "S")
{
         setsel(obj,"Any Price","","0");
    setsel(obj,"£30,000","30000",n);n=n+1;
    setsel(obj,"£40,000","40000",n);n=n+1;
    setsel(obj,"£50,000+","",n);n=n+1;
         } else {
          setsel(obj,"Any p/month","","0");
    setsel(obj,"£300","300",n);n=n+1;
    setsel(obj,"£400","400",n);n=n+1;
    setsel(obj,"£500+","",n);n=n+1;
         }    
    }        
    $(document).ready(function() {
        onChange(document.propsearch_res);
    });
    function setsel(obj,val1,val2,n) {
       obj.price_low.options[n] = new Option(val1,val2);
       obj.price_high.options[n] = new Option(val1,val2);
    }
</script>

Original Form Code (replace first drop down with 2 radio buttons)

        <form id="propsearch_res" name="propsearch_res" method="post" action="script_search.php"> 
            <fieldset><legend>Property Search Type</legend> 
                 <span><span id="propsearch1"> 
                    <label for="sales_rental"><img src="images/ico_search.png" alt="Property Search: Step 1" />Search:</label> 
                    <select name="sales_rental" id="sales_rental" onChange="onChange(this.form)"> 
                        <option value="S" selected="selected">Properties For Sale</option> 
                        <option value="L">Properties To Let</option> 
                    </select> 
                 </span></span> 
            </fieldset> 
            <p>Filter search by particulars</p> 
            <fieldset><legend>Search Particulars</legend> 
                <div id="propsearch2">                          
                    <div> 
                        <label for="PropTypwfld"><img class="house" src="images/ico_house.png" alt="Property Search: Step 2" />Search for a:</label> 
                        <select name="type" id="PropTypefld" size="1"> 
                            <option value="">Property</option> 
                            <script type="text/javascript" src="http://www.housescape.org.uk/cgi-bin/ptype.pl?ren1"></script> 
                        </select> 
                    </div> 
                    <div> 
                        <label for="area">loacted in:</label> 
                        <select name="area" id="area" size="1"> 
                            <option value="">All Areas</option> 
                            <script type="text/javascript" src="http://www.housescape.org.uk/cgi-bin/arealist.pl?ren1"></script> 
                        </select> 
                    </div> 
                    <div> 
                        <label for="Bedroomsfld">with a minimum:</label> 
                        <select name="num_beds" id="Bedroomsfld" size="1">                          
                            <option value="1">1 Bedroom</option> 
                            <option value="2">2 Bedrooms</option> 
                            <option value="3">3 Bedrooms</option> 
                            <option value="4">4 Bedrooms</option> 
                            <option value="5">5 Bedrooms</option> 
                            <option value="6">6 Bedrooms</option> 
                            <option value="">No Preference</option> 
                        </select> 
                    </div>                   
                    <div> 
                        <label for="price_low">between:</label> 
                        <select name="price_low" id="price_low" size="1"></select> 
                    </div> 
                    <div> 
                        <label for="price_high">and:</label> 
                        <select name="price_high" id="price_high" class="lastinput" size="1"></select> 
                    </div> 
                </div> 
            </fieldset> 
            <fieldset class="controls"> 
                <input name="xstyle" id="xstyle" type="hidden" value="" /> 
                <input name="submit" id="submit" type="submit" onClick="nongeosearch()" value="Search Properties" /> 
            </fieldset> 
        </form>  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T17:10:35+00:00Added an answer on May 17, 2026 at 5:10 pm

    Form: change the select element to this.

    <label for="sales_rental0">Properties For Sale</label><input type="radio" id="sales_rental0" name="sales_rental" value="S" checked />
    <label for="sales_rental1">Properties To Let</label><input type="radio" id="sales_rental1" name="sales_rental" value="L" />
    

    change $(document).ready to this.

    $(document).ready(function(){
        onChange(document.propsearch_res);
    
        $("input[name=sales_rental]").click(function(){
            onChange(document.propsearch_res);
        });
    });
    

    then you should also remove the id in your radio button since id is unique and remove the onChange event on the radio button.

    For your onChange function change to this.

    function onChange(obj) {
        var n = 1;
        obj.price_low.options.length = 0;
        obj.price_high.options.length = 0;
    
        if (getRadioButtonValue(obj.sales_rental) == "S")
        {
            setsel(obj,"Any Price","","0");
            setsel(obj,"£30,000","30000",n);n=n+1;
            setsel(obj,"£40,000","40000",n);n=n+1;
            setsel(obj,"£50,000+","",n);n=n+1;
        } else {
            setsel(obj,"Any p/month","","0");
            setsel(obj,"£300","300",n);n=n+1;
            setsel(obj,"£400","400",n);n=n+1;
            setsel(obj,"£500+","",n);n=n+1;
        }    
    }   
    

    Lastly add this function in your script.

    function getRadioButtonValue(radio) {
        if(radio.length > 0) {
            for(var i=0; i<radio.length; i++) {
                if(radio[i].checked) {
                    return radio[i].value;
                }
            }  
        }
    }
    

    Edit:

    For the scripts dropdown menu’s don’t put the <scripts> inside the <select> tag.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web form that I am attempting to implement dynamic drop down
I have a web form that has multiple ListBoxes, TextBoxes, DropDowns. If I put
I have dropdown list control in one of my application and when I add
I have a dropdown list that stores name/value pairs. The dropdown appears in each
I have a dropdown box and a literal tag inside an Update Panel. On
I have a dropdown, I have a datasource, I have AutoPostBack set to true
Is there any way to have a dropdown in excel that will show a
So, I have an autocomplete dropdown with a list of townships. Initially I just
I have a custom built ajax [div] based dynamic dropdown. I have an [input]
I have three values I need to align in a dropdown box. How can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.