Disable button when none selected
Q:
How can i disable a button within a form untill a selection is made, for example when using a poll form ?
A:
Use this piece of JavaScript to initially disable (true) the button and when a visitor makes a selection it enables (false) the button with an OnClick event.
Example code:
<form name="Poll" method="post" action="">
<table>
<tr>
<td>
<input type="radio" name="radiobutton" value="radiobutton" onClick="document.Poll.Submit.disabled=false">
</td>
<td>1</td>
</tr>
<tr>
<td>
<input type="radio" name="radiobutton" value="radiobutton" onClick="document.Poll.Submit.disabled=false">
</td>
<td>2</td>
</tr>
<tr>
<td>
<input type="radio" name="radiobutton" value="radiobutton" onClick="document.Poll.Submit.disabled=false">
</td>
<td>3</td>
</tr>
<tr>
<td>
<input type="radio" name="radiobutton" value="radiobutton" onClick="document.Poll.Submit.disabled=false">
</td>
<td>4</td>
</tr>
<tr>
<td>
<input type="radio" name="radiobutton" value="radiobutton" onClick="document.Poll.Submit.disabled=false">
</td>
<td>5</td>
</tr>
<tr>
<td>
<input type="submit" name="Submit" value="Submit">
</td>
<SCRIPT language="JavaScript">
document.Poll.Submit.disabled=true;
</SCRIPT>
</tr>
</table>
</form>
Example output: