Scripts
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb Site ManagementScripts

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 Dev Shed Forums Sponsor:
  #1  
Old February 10th, 2008, 07:08 AM
baioslaio baioslaio is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 1 baioslaio User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 30 sec
Reputation Power: 0
Question Poll with 3 choices?

Is it possible to make a poll where you can choose 3 options and then everything turns gray or something?

Reply With Quote
  #2  
Old February 12th, 2008, 11:18 AM
acidedge2004 acidedge2004 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Posts: 123 acidedge2004 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 h 49 m 9 sec
Reputation Power: 1
Hey baioslaio, welcome to devshed! This is my first script (written in Javascript) so it may be a little raw but it does what I think you are looking for.

I am guessing that by everything going grey you mean the options (check boxes in my example) become disabled.

Code:
  <head>  
<script type="text/javascript" language="javascript">

function checkTicks() {
//cache document.form1.myboxes as it will be accessed repeatedly throughout the script
//will make the script more efficient
y = document.form1.myboxes;

//Initialise x and set it to 0 (will be used to determine 
//if there are 3 checked boxes)
x=0; 
//Access all the check boxes
for (i=0;i<y.length;i++) {

//If checked then add one to x
  if (y[i].checked==true) {
    x++;
  }
}
//If three check boxes are checked then disable them
//but keep them checked
   if (x==3){
    for (i=0;i<y.length;i++) {
      y[i].disabled=true;
      //changes background to grey
      document.bgColor="CCCCCC";
    }
   }
}
//Function to uncheck and re-enable all the boxes
//Used onload and with reset button
function enableBoxes() {
y = document.form1.myboxes;
  for (var i=0;i<y.length;i++){
  y[i].disabled=false;
  y[i].checked=false;}
  //resets background to default
  document.bgColor="";
}
</script> 
  </head>  
  <body onload="enableBoxes()">
    <div>
      <form id="form1" name="form1"><h2>Question</h2>Asnwer 1
        <input type="checkbox" name="myboxes" onClick="checkTicks()">
        <br/>Answer 2
        <input type="checkbox" name="myboxes" onClick="checkTicks()">
        <br/>Answer 3
        <input type="checkbox" name="myboxes" onClick="checkTicks()">
        <br/>Answer 4
        <input type="checkbox" name="myboxes" onClick="checkTicks()">
        <br/>
        <input type="button" value="reset" onClick="enableBoxes()">
        </p>
      </form> 
    </div> 


I have tried to comment the code as much as possible for you (without making it look too clutteed) so you can see what is happening and adapt it as you want. The document.bgcolor=""; parts can be deleted without affecting the script, so feel free. I added it as I was not sure if you wanted the background to go grey or if you meant disable the check boxes.

I know that I have re-used some things, such as when trying to cache the document.form1.myboxes part of the code, I do not know why but when I tried to make it global by making it outside the functions it would not work, so more experienced developers feel free to solve that!

Hope this helps, if you have any questions about the code feel free to ask,
Mike

Last edited by acidedge2004 : February 12th, 2008 at 11:24 AM.

Reply With Quote
  #3  
Old February 24th, 2008, 06:20 AM
AndrewJ AndrewJ is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 24 AndrewJ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 56 m 2 sec
Reputation Power: 0
PollDaddy might provide what you need. It's great.


Andrew

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb Site ManagementScripts > Poll with 3 choices?


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 6 hosted by Hostway
Stay green...Green IT