catch data from javascript using json to make a query in PHP -


hello im using code javascript tutorial wich works great.. rating star system, can ask users, skills on , can "answer" using rating system,....

so need "catch" value.. (using json? or thats have been reading here) insert on database

can store value on $_session?.. because great im using steps formulary,.... each step storing variables in session @ last step insert using php in mysql database.

as see data ready bee send :d thats great , how catch , , store in $_session. in advance!!

also asume can asign id or send multiple rates 1 page,

this not specified on code, , im pretty bad javascript.. (thats why ask wisdom people on stackoverlflow)

this code rating system here http://reignwaterdesigns.com/ad/tidbits/rateme/

/* author: addam m. driver date: 10/31/2006 */  var smax;   // isthe maximum number of stars var holder; // holding pattern clicked state var preset; // preset value onces selection has been made var rated;  // rollover image stars // function rating(num){     smax = 0;   // isthe maximum number of stars     for(n=0; n<num.parentnode.childnodes.length; n++){         if(num.parentnode.childnodes[n].nodename == "a"){             smax++;          }     }      if(!rated){         s = num.id.replace("_", ''); // selected star         = 0;         for(i=1; i<=smax; i++){                  if(i<=s){                 document.getelementbyid("_"+i).classname = "on";                 document.getelementbyid("ratestatus").innerhtml = num.title;                     holder = a+1;                 a++;             }else{                 document.getelementbyid("_"+i).classname = "";             }         }     } }  // when roll out of the whole thing // function off(me){     if(!rated){         if(!preset){                 for(i=1; i<=smax; i++){                      document.getelementbyid("_"+i).classname = "";                 document.getelementbyid("ratestatus").innerhtml = me.parentnode.title;             }         }else{             rating(preset);             document.getelementbyid("ratestatus").innerhtml = document.getelementbyid("ratingsaved").innerhtml;         }     } }  // when rate // function rateit(me){     if(!rated){         document.getelementbyid("ratestatus").innerhtml = document.getelementbyid("ratingsaved").innerhtml + " :: "+me.title;         preset = me;         rated=1;         sendrate(me);         rating(me);     } }  // send rating information somewhere using ajax or that. function sendrate(sel){     alert("your rating was: "+sel.title); } 

replace alert in sendrate() function ajax call php script. need use ajax library, such jquery, post value server. (see http://api.jquery.com/jquery.post/)

example:

$.post('/path/to/php', {rating: sel.title}, function (data) {     alert('saved, server responded with' + data); }); 

Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -