View Full Version : Remove drop down option based on radio button choice

06-12-2010, 03:37 AM
I have a radio button that asks Does your URL exist or need to be purchased? and a drop down menu that lists different types of web projects (i.e. new website and website redesign).

What I'm trying to achieve is, if the user selects that the URL exists, I would like the drop down menu option new website to be removed from the list.


<input type="radio" name="website_status" value="exists"/> Exists
<input type="radio" name="website_status" value="purchase_required"/> Needs to be purchased

<select name="projects">
<option value="new_website">New Website</option>
<option value="website_redesign">Website Redesign</option>

window.onload = initForms;

function initForms() {
for (var i=0; i<document.forms.length; i++) {
document.forms[i].onsubmit = function() {return validForm();}

function validForm() {
var inputarray = document.getElementsByTagName("input");
var selectarray = document.getElementsByTagName("select");
var textarea = document.getElementsByTagName("textarea");

if (inputarray[0].checked == true) {
return false;

I've been experimenting with this for the last couple hours and am getting nothing! :( Could someone please point me in the right direction?