Debt Consolidation - Online Advertising - Debt Consolidation - Insurance Quotes - Deaf Topics

PDA

View Full Version : Enable multiple checkboxes in a page


drors30
Jan 13th 2008, 1:32 am
Hi all,
The following question is based on a sample appears at w3schools at :
http://www.w3schools.com/php/php_ajax_database.asp

I want to build a similar page but instead of one check box i will have 3-4 check boxes
in one page.
Each of them will call a different Javascript that goes through a different php page and displays the
results of the query in a different table.

How can i achieve this ?

barts2108
Feb 9th 2008, 1:09 pm
I would say to create 4 functions

<select name="users" onchange="showUser1(this.value)">
....

<select name="users" onchange="showUser2(this.value)">
....

<select name="users" onchange="showUser3(this.value)">
....

<select name="users" onchange="showUser4(this.value)">
....

And modify the functions to fit your needs.

On the server you can create 4 php files.. one for each
combo box on your page. If you prefer to keep only one
php file you can add another variable in the call to the
php file

from the w3schools example

var url="getuser.php"
url=url+"?q="+str

would be something like: (function 1)

var url="getuser.php"
url=url+"?func=1&q="+str

function2
var url="getuser.php"
url=url+"?func=2&q="+str

etc.

in the php file you can distinguish between the different calls
by looking at

if ($_GET['func'] == 1)
{// code for function 1}
if ($_GET['func'] == 2)
{// code for function 2}
if ($_GET['func'] == 3)
{// code for unction 3}
if ($_GET['func'] == 4)
{// code for function 4}

Or if you not like too many 'if' statments

swtich($_GET['func'])
{
case 1:
//code for function 1
break;
case 2:
//code for function 2
break;
case 3:
//code for function 3
break;
case 4:
//code for function 4
break;
default:
//code for non-existing function code
break;

}