[eluser]edwin87[/eluser]
Okay i forgot a parameter what is really stupid.
Code:
$('#building').linkedSelect('<?php echo base_url();?>index.php/buildings/selectbox/building','#levels',{firstOption: 'Select a level'});
It has to be something like this:
Quote:classname/function/parameter1/parameter2
Parameter1 : Building
Paramater2 : Id to search.
But how can i fill parameter 2?
The example script with php was:
Code:
<?php
$json = array();
// Lets get the variables we passed
$search = isset($_GET['search']) ? (string) $_GET['search'] : '';
$str = isset($_GET['str']) ? (string) $_GET['str'] : '';
// Cleans query string before we run the selects below.
// Allows A-Z, a-z, 0-9, whitespace, minus/hyphen, equals, ampersand, underscore, and period/full stop.
$str = preg_replace("/[^A-Za-z0-9\s\-\=\&\_\.]/","", $str);
$str = mysql_real_escape_string($str);
switch ($search) {
case "building":
$sql = mysql_query("SELECT * FROM Levels WHERE BuildingPart_ID = '{$str}'");
while ($rows = mysql_fetch_array($sql)) {
$json[] = "{optionValue: ".$rows["Level_ID"].", optionDisplay: '".$rows["Name"]."'}";
}
echo '[' . implode(',', $json) . ']';
break;
case "levels":
$sql = mysql_query("SELECT * FROM Rooms WHERE Level_ID = '{$str}'");
while ($rows = mysql_fetch_array($sql)) {
$json[] = '{"optionValue": "'.$rows["Room_ID"].'", "optionDisplay": "'.$rows["Name"].'"}';
}
echo '[' . implode(',', $json) . ']';
break;
case "rooms":
$sql = mysql_query("SELECT * FROM Segmenten WHERE Room_ID = '{$str}'");
while ($rows = mysql_fetch_array($sql)) {
$json[] = '{"optionValue": "'.$rows["Segment_ID"].'", "optionDisplay": "'.$rows["Name"].'"}';
}
echo '[' . implode(',', $json) . ']';
break;
default:
echo "Something has gone wrong!";
break;
}
?>
You can see it want to use 2 get vars.
The first one i can fill.
But the second one does not work.