HTML, JavaScript And CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingHTML, JavaScript And CSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old October 30th, 2004, 12:01 AM
webb webb is offline
Help and be helped
ASP Free Novice (500 - 999 posts)
 
Join Date: Feb 2004
Location: Australia
Posts: 505 webb User rank is Sergeant (500 - 2000 Reputation Level)webb User rank is Sergeant (500 - 2000 Reputation Level)webb User rank is Sergeant (500 - 2000 Reputation Level)webb User rank is Sergeant (500 - 2000 Reputation Level)webb User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 6 Days 13 h 21 m 32 sec
Reputation Power: 21
Red face Enable submit button problem

I'm using this code to enable the sumbit button.

The problem is that it enables on odd numbers of ticks once even it disables thee button.

Basically it disables the checkbox until one checkbox is ticked.

Code:
  
<input type="checkbox" onClick="document.all['mysubmit'].disabled =(document.all['mysubmit'].disabled)? false : true">
<input type="submit" id="mysubmit" value="submit" disabled>
 


I just want it to enable if 1 or all checkboxes are ticked.

Can anyone help me out.

Thank you
__________________
Life is Good

Reply With Quote
  #2  
Old October 30th, 2004, 04:46 AM
Lafinboy's Avatar
Lafinboy Lafinboy is offline
The Laughing Moderator
ASP Free Loyal (3000 - 3499 posts)
 
Join Date: Apr 2004
Location: Sydney, Australia
Posts: 3,267 Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)  Folding Points: 29199 Folding Title: Starter FolderFolding Points: 29199 Folding Title: Starter Folder
Time spent in forums: 2 Weeks 1 Day 10 h 48 m 12 sec
Reputation Power: 15
Send a message via ICQ to Lafinboy Send a message via AIM to Lafinboy Send a message via MSN to Lafinboy Send a message via Yahoo to Lafinboy Send a message via Skype to Lafinboy
This should work for you:
Code:
<form name="form1" id="form1">
<input type="checkbox" name="checkbox" id="chk" onChange="chkCount();" /><br />
<input type="checkbox" name="checkbox" id="chk" onChange="chkCount();" /><br />
<input type="checkbox" name="checkbox" id="chk" onChange="chkCount();" /><br />
<input type="submit" name="submit" id="submit" disabled="disabled" />
</form>
<script language="javascript" type="text/javascript">
function chkCount()
{
// assign a 0 value to the number of selected checkboxes variable
var chkTotal = 0;
// loop though the checkboxes and count how many are checked
for(counter=0;counter<document.form1.checkbox.length;counter++)
{
if(document.form1.checkbox[counter].checked)
{
chkTotal = chkTotal + 1;
}
}
// if at least 1 checkbox is checked, activate the submit button
if (chkTotal > 0)
{
document.form1.submit.disabled=false;
}
else
// leave the submit button disabled
{
document.form1.submit.disabled=true;
}
}
</script>

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingHTML, JavaScript And CSS Help > Enable submit button problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT