Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making a Submit Button appear dynamically

Status
Not open for further replies.

codehead

Programmer
Aug 25, 1999
96
US
Hello All:

I want to make a Submit Button appear when a check box is checked on a form. Does anyone know how to do this or can anyone point me to a similar example that I could adapt to my usage?

Thanks!

 
this is actually a javascript question..post in that forum for a better answer, but here is an example code...

Code:
<form action="post" action="your_processor" onsubmit="return false;"> 
<input type ="checkbox" name="agree" value="anything"> 
<b>Click me or the buck stops here.</b> 
<input type="submit" name="submitbutton" onClick="check_agree(this.form);" value="Go"> 
</form> 
<script language="javascript"> 
function check_agree (form) { 
if (form.agree.checked) { 
form.submitbutton.disabled = true; 
form.submit(); 
} 
else { alert('if you don\'t agree, we set you free.'); } 
} 

</script>

-DNG
 
Hi DNG,

There seems to be a logic flaw....when I check the checkbox, I get the "else" message, instead of the Submit Button being disabled.

Thanks!


 
are you sure that you named the form fields correct...check your submit button name and check box name

the above example runs fine for me...

-DNG
 
Could it not be working because I'm using multiple checkboxes (under the same checkbox name) that are being populated from a database?

<table>
<tr>
<% do while not tl_org.EOF %>
<td><input type="checkbox" name="TL_ORG" value="<% = tl_org("ORGANIZATION") %>" onClick="disSubBut(this.form);"></td><td><strong><% = tl_org("ORGANIZATION") %></strong></td>
<% tl_org.movenext %>
<% Loop %>
</tr>
</table>

 
thats should not be a problem i guess because in anycase we are doing

if (form.[red]yourcheckboxname[/red].checked)

did you post this question javascript forums...i am sure you will get a better reply there...

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top