2
I’m making a form, and I didn’t find anything like it in the research I did.
I have the code http://jsfiddle.net/rubensoul/xdmz35oy/3/ I’m getting popular them normally,
When selecting a date he populates the region, popular the region populates a professional, and popular the professional, he populates the time.
However, I need to select a 'complementary exam type' checkbox, it brings professional JSON information and also checkbox information to the time select. What I need is to create an array that has both professional and checkbox ids on time.
i need then, that the 2 parameters (professional and (type of exam) were sent to the same array, and return to select (schedules) I am using a switch case of json
I have to pass the checkbox parameter and it interact with the professional array, and update the schedule, that’s basically it
<?php
header('Content-type: text/json'); $retorno = array();
switch($_POST['profissional']) { case '21': //
$retorno = array( 0 => "Selecione um horário",
41 => "18h30",
);
break; case '24': //
$retorno = array( 0 => "Selecione um horário",
42 => "18h50",
);
break;
case '27': //
$retorno = array( 0 => "Selecione um horário",
43 => "20h30",
);
break; case '30': //
$retorno = array( 0 => "Selecione um horário",
44 => "20h00",
);
break;
case '33': //
$retorno = array( 0 => "Selecione um horário",
45 => "22h45",
);
break;
case '35': //
$retorno = array( 0 => "Selecione um horário",
46 => "22h00",
);
break; }
echo json_encode($retorno);
?>
// call to checkbox
<?php
header('Content-type: text/json');
$retorno = array();
switch($_POST['inlineCheckbox1'])
{
case 'option1': // regiao 1
$retorno = array(
0 => "Selecione um horário (checkbox)",
91 => "18h30",
95 => "19h30",
);
break;
case 'option2': // regiao 2
$retorno = array(
0 => "Selecione um horário (checkbox)",
92 => "18h50",
99 => "22h50",
);
break;
case 'option3': // regiao 2
$retorno = array(
0 => "Selecione um horário (checkbox)",
93 => "20h30",
97 => "22h30",
);
break;
}
echo json_encode($retorno);
?>
How can I make this change in the array to receive the 2 parameters?
Can anyone help me? Thanks in advance.
If I understand correctly you want when the user selects a checkbox to go a request to the server that returns a JSON and you want that information to go to the select "Available Times"... is that it? What is not working? Any errors? In AJAX you are sending
data: {inlineCheckbox1: $("#inlineCheckbox1").val()},
but I don’t see in PHP where you’re using thatinlineCheckbox1
.– Sergio
Hello, @Sergio can help me again?
– Rubens Junior