Digital Point Forums
iKobo

Go Back   Digital Point Forums > Design & Development > Programming > JavaScript
Google Analytics
Log In to view
your analytics

Reply
 
Thread Tools
  #1  
Old Mar 31st 2005, 1:06 am
star star is offline
Peon
 
Join Date: Mar 2005
Posts: 1
star is on a distinguished road
Unhappy Checkbox

Hi Experts,
I need some coding in javascript using checkbox. I got some 5 checkboxes options. There r 2 buttons users can choose more than 1 check box and clicks the button 1 and it is stored into the dbase.

Only 1 checkbox should be allowed to choose if the user chooses the button 2. If the user chooses more than 1 option an alert message should be displayed. Pls help. Anybody got any sample coding for this. Suggestions r highly appreciated. Thank You.

Regards,
Star
Reply With Quote
  #2  
Old Mar 31st 2005, 8:48 am
marty marty is offline
Champion of the Naaru
 
Join Date: Mar 2005
Posts: 154
marty is on a distinguished road
What browser(s) are you developing for?

The are a ton of ways to do what you need. Unfortunately, without knowing what browsers and browser versions you are supporting it's impossible to give you a definitive solution, but this should get you started for on IE5+, NN6+, Mozilla, and Safari:

<input type="checkbox" name="ddd" value="" checked>
<input type="checkbox" name="ddd" value="" checked>
<input type="checkbox" name="ddd" value="">
<input type="checkbox" name="ddd" value="">
<input type="submit" name="sdfsd">
<script language="JavaScript" type="text/javascript">

//alert(document.getElementsByTagName("input").length)

var foundCount = 0
for(i=0;i<document.getElementsByTagName("input").length;i++)
{
if(document.getElementsByTagName("input")[i].type == "checkbox")
{
//alert(document.getElementsByTagName("input")[i].checked)
if(document.getElementsByTagName("input")[i].checked == true)
{
foundCount++
}
}

}

if(foundCount > 1){
alert("Emergency Will Robinson")
}

</script>

Good luck
Reply With Quote
Reply

Bookmarks

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -8. The time now is 2:18 am.