PDA

View Full Version : Retrieve values from radio buttons



Harm Millaard
06-30-2011, 01:07 PM
This is probably a very basic question, but I have trouble finding the solution and maybe someone can help me or direct me to some other sites.

I have a page here: http://ppbm5.com/DB-PPBM5-3.php

There are 9 tabbed panels with a number of radio buttons,

http://www.millcon.nl/Harm/29-6-2011 23-57-13.png

and below that is a list of records from a MySQL database.

I want the following to happen:

1. When a radio button is clicked, I want to retrieve the value associated with the button.
Should I use a hidden button with the 'On-click' property? How do I retrieve the value?

2. I want to add that value to a variable used in a WHERE statement and update the mysql_query ("whatever").

Example: When someone clicks on 'Asus' and the database is queried with the corresponding WHERE xxx ='Asus' , the number of records found goes down from 328 to say 91.

3. After moving to another tab and clicking on another radio button, I want to retrieve the value associated with that button.

4. I want to add that value to the previous variable and used in the WHERE statement and again update the mysql_query("whatever", "next choice").

This also implies that the query itself must be embedded in a function to update the list of records from whatever tab one clicks.

I hope you get my drift and can offer some suggestions.

JoeDaStudd
06-30-2011, 03:16 PM
Just use the onClick function against the radio buttons.

To refresh the query you can use ajax.
Nice ajax examples here (http://www.w3schools.com/php/php_ajax_database.asp).

So essentially you have something like this.
1. radio button clicked
2. javascript function to call php page (ajax)
3. php page query table based on new information
4. javascript function retrieves the output from php page
5. javascript function displays the output