Web Design Forum  
 
Go Back   Web Design Forum > Web Software > Scripts

Reply
 
LinkBack Thread Tools Display Modes
Old 02-22-2009, 11:30 PM   #1
New Member
 
Join Date: Feb 2009
Posts: 3
Default poll with ajax support.limited number of choices

I have to make a poll with many checkbox'es. I want to use php with AJAX for my purpose.
1)Is it possible to limit number of user choices with the helps of AJAX?I want to accept only 3 choices. how to do that?

2)Is it possible to get order of choices and how? - It's important for me know in which order user choose items of the poll
linderox is offline   Reply With Quote


Old 02-23-2009, 02:43 AM   #2
Super Moderator
 
jnjc's Avatar
 
Join Date: Jun 2008
Posts: 493
Thumbs up

You would probably be better using javascript to achieve both of these requirements.

1) Using JS to see how many boxes are checked would be easier then trying to do this using ajax.

2) This could be a tricky one as what happens if the user checks a box unchecks it, checks some more boxes and checks it again ? As far as I can see you have to do this client side and JS would be your best bet. Your simplest way to do it would be to have a 'value-changed' trigger that adds the ID of the select box onto a string, then send the string back with the Ajax call.

Something like:

HTML:
Code:
	<input onclick="TrackChange(this);" type="checkbox" id="test1" value="">
	<input type="hidden" id="Tracker" value="">
Javascript:

Code:
function TrackChange(oField) {
 var action ="u";  
 if (oField.checked) action = "c";
 action = action + oField.id;	
 document.getElementById("Tracker").value  =
    document.getElementById("Tracker").value + action + ",";
}
The value of 'Tracker' will have a list of field Id's with a prefix C if they where checked and u if unchecked. You could then use server side code to make sense of the values.

HTH,
JC
jnjc is offline   Reply With Quote
Old 02-23-2009, 04:48 AM   #3
New Member
 
Join Date: Feb 2009
Posts: 3
Default

thank you... now I have to find a good book about AJAX and java script or maybe a good example. what about the last one?
linderox is offline   Reply With Quote
Old 02-23-2009, 05:41 AM   #4
Super Moderator
 
jnjc's Avatar
 
Join Date: Jun 2008
Posts: 493
Default

Quote:
Originally Posted by linderox View Post
thank you... now I have to find a good book about AJAX and java script or maybe a good example. what about the last one?
I thought my example was good ....

jnjc is offline   Reply With Quote
Old 02-23-2009, 11:58 AM   #5
New Member
 
Join Date: Feb 2009
Posts: 3
Default

yes! I didn't understand anything. I should try to study javascript a little )
linderox is offline   Reply With Quote


Reply

Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:08 AM.


Camera Forum - Computer Forum - Web Design Forum

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO 3.6.0 ©2011, Crawlability, Inc.