/    Sign up×
Community /Pin to ProfileBookmark

Javascript Voting System

Hello all.
In this post I do not ask for a complete script, but for an explanation…
I’ve been programming these past few months a lot with php, but its past time now that I start create javascript pages for better accessibility and feel.

In this case, my aim is to create a simple feedback system with voting capacities.

I have divs (representing stars) that change color when clicked on using javascript. They change size too, depending on what level it was posted (for example, if user votes for 5 stars, the div becomes big and changes color). Its just a nice looking thing….
But its useless unless I can use it to process the votes and send them in a database.

So here is what I’d like to do, but don’t know how:
User votes for all the questions on the page, then i have a button that send the votes to the database such as:

Do you like…
apples? ◌1 ◌2 ◌3 ◌4 ◌5
oranges? ◌1 ◌2 ◌3 ◌4 ◌5
[INDENT][Vote][/INDENT]

Now how could I make user click on a div, without reloading the page, then send them to a database and by mail?
Cause if it was radio checkboxes it would be easy… but its divs or images and I don’t know how to memorize the selection and then use it with php.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@CrazyMerlinAug 25.2007 — you can use a javascript function that creates an xmlHttpRequest object (look it up) and have that send the data to a php script which in turn does the processing and then reports back....all without refreshing the page.

Look up basics of Ajax.
Copy linkTweet thisAlerts:
@rwtauthorAug 31.2007 — Okay, thanks....

Is this the way you would do it?

... I mean, using javascript and stuff!?
×

Success!

Help @rwt spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.21,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...