I'm Miserable. Trying To Pass Jscript Var To PHP Query
Posted: Tue Dec 22, 2009 12:28 pm
Hey, we have a page with 6 surveys and, for now, one block of PHP code that generates JSON. The goal of the JSON is to take the results of that question and display it to the user (We have jquery functions that successfully work with the JSON)
The JSON loads fine and the display of the results is working. The problem is that with 6 questions displayed, the JSON only recognizes the question_id of the last question when looping through a db.
In other words, if I choose survey 3, it doesn't recognize it. I am able to capture the vote using Jquery POST. But when I want the JSON to reflect THAT vote and the live snapshot of results for the CHOSEN question, it can't read it. Instead, it only reads the question ID of the last question looped from a database. How do I get my PHP code, which generates the JSON, to query the results of the question ID of the CHOSEN question instead of the last one that's looped through the DB?
Here is what I have:
1.) I CAN grab the q_id via javascript. I just can't append it to the darn PHP query that spits out JSON when the page loads
That's another issue, the darn thing should be generating upon click. I can probably work that out but what I can't work out is
passing the variable to the PHP json generating query:
Here is the code for the css 'submit button'
The PHP code generates this:
What I am not showing, for sake of not overloading you, is that I successfully can read the click of a submit button and add the vote. the voting process works perfectly, it's just that the JSON won't load the live results of that question from the db.
How do I do THAT?
Thanks
PS. I can modify code examples/show more upon request. I just don't want to overload anybody or confuse anybody. TY so much for your time.
PPS. The form you see is listed as 'first form'. What I am not really showing, in detail, is that I can track the submit of a button and
find out which qid was chosen. What I can't do is take that var
The JSON loads fine and the display of the results is working. The problem is that with 6 questions displayed, the JSON only recognizes the question_id of the last question when looping through a db.
In other words, if I choose survey 3, it doesn't recognize it. I am able to capture the vote using Jquery POST. But when I want the JSON to reflect THAT vote and the live snapshot of results for the CHOSEN question, it can't read it. Instead, it only reads the question ID of the last question looped from a database. How do I get my PHP code, which generates the JSON, to query the results of the question ID of the CHOSEN question instead of the last one that's looped through the DB?
Here is what I have:
1.) I CAN grab the q_id via javascript. I just can't append it to the darn PHP query that spits out JSON when the page loads
That's another issue, the darn thing should be generating upon click. I can probably work that out but what I can't work out is
passing the variable to the PHP json generating query:
Here is the code for the css 'submit button'
Code: Select all
<a href="#" rel="#mies1" id="upny_sresbtn1" ><span>Submit!</span></a>Code: Select all
var upny_iniresults = {
"q_cdata" : [
{ "a_id" : "9", "a_txt" : "Yes", "a_perc" : "3.45", "t_r" : "1" },
{ "a_id" : "10", "a_txt" : "No", "a_perc" : "13.79", "t_r" : "4" },
{ "a_id" : "11", "a_txt" : "Not Sure", "a_perc" : "24.14", "t_r" : "7" },
{ "a_id" : "26", "a_txt" : "Maybe", "a_perc" : "24.14", "t_r" : "7" }
};
How do I do THAT?
Thanks
PS. I can modify code examples/show more upon request. I just don't want to overload anybody or confuse anybody. TY so much for your time.
PPS. The form you see is listed as 'first form'. What I am not really showing, in detail, is that I can track the submit of a button and
find out which qid was chosen. What I can't do is take that var