View Full Version : hiding/disabling the submit button based on dropdown selection

11-09-2010, 08:27 PM
How can I hide/disable the submit button if the name Todd is selected?


<form name="people">
<select name="group">

<option value="Pick Your Name">Choose</option>
<option value="Tom">Tom</option>
<option value="Freddy">Freddy</option>
<option value="Todd">Todd</option>
<option value="Fred">Fred</option>
<option value="William">William</option>
<option value="Johnson">Johnson</option>
<INPUT TYPE=submit VALUE="submit">

Old Pedant
11-09-2010, 08:39 PM
<select name="group" onchange="if (this.value=='Todd') this.form.DoSubmit.style.display='none';">
<input type="submit" name="DoSubmit" value="submit" />

Old Pedant
11-09-2010, 08:41 PM
Or (not both...one or the other):

<form name="people" onsubmit="return ( this.form.group.value != 'Todd');" >

11-09-2010, 08:48 PM
Can I make this a little harder. What if I select Todd and the submit button is hidden and then click on another name can the submit button reappear?

Old Pedant
11-09-2010, 09:19 PM
<select name="group"
onchange="this.form.DoSubmit.style.display = (this.value=='Todd') ? 'none' : 'inline';">

Old Pedant
11-09-2010, 09:20 PM
I assume you are playing a trick on a friend?

11-09-2010, 09:52 PM
<select name="group"
onchange="this.form.DoSubmit.style.display = (this.value=='Todd') ? 'none' : 'inline';">

Thanks Old Pedant...

This is not a trick. I am running a league and getting frustrated when people submit their choices in at the last minute. So I wanted to give each person 3 times where they can hand in their choices late, after that I want to hide their submit button after the deadline has hit.

Thanks again

Old Pedant
11-09-2010, 10:10 PM
Not to ask a dumb question, but... Why not simply remove their name from the list, instead of blocking them?