All pastes #995553 Raw Edit

Stuff

public text v1 · immutable
#995553 ·published 2008-04-24 08:40 UTC
rendered paste body
<?php
include ('includes/db.php');
if ($_REQUEST['action'] == 'ajax') {
$otdel=$_REQUEST['value'];
$query = "SELECT `disciplina` FROM `disciplina` WHERE `otdel` LIKE '$otdel'";
$result = mysql_query ($query) or die ("Query failed : " . mysql_error ());
while  ($line = mysql_fetch_array ($result, MYSQL_ASSOC)) {
        $out .= "<option>".$line['disciplina']."</option>";
}
mysql_free_result ($result);
mysql_close ($link);
echo $out;
exit();
}
?>
<html>
<head>
<meta content="text\html"; charset="UTF-8" http-equiv="content-type">
<script src="js/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
    $("#chk1").change(function(){
        if (this.checked){
            var $chk_val=this.value;
            $.get("p.php?action=ajax&value="+$chk_val, function(data){
            $(data).appendTo("#select");
            });}
    });
});
</script>
</head>
<body id=body>
<form id=mysql>
<input type="checkbox" id=chk1 value="151001 (ТМ)">
<select id="select">
</select>
</form>
</body>
</html>