I try to integrate a PHP Site with a "depending dropdown List" (using Javascript) into my Wordpress site. When I run the PHP Site "outside" Wordpress (which means the whole URL like: "www.xxx.com/wp-content/themes/lawyerplus/upload.php") then everything works as expected - which means the "dependend dropdown lists" will be filled, but when I run the same page within wordpress: www.xxx.com/upload/ then the javascript will not run, and so the lists will not be filled.
So the Question will be: How can I tell Wordpress, that it should run the Javascript files inside the PHP Files which will be integrated using the Wordpress Plugin "MaGiKS Proper PHP Include"?
Here is the part in upload.php where the Rubrik(Category) will be called. This is working, so the Category (Rubrik) will be showed.
<tr>
<td>Rubrik*</td>
<td><? include "test.php"; ?></td>
</tr
Here is the content of test.php
<?php include('config.php');
mysql_query("SET CHARACTER SET 'utf8'");
$query_parent = mysql_query("SELECT DISTINCT cat_id, category FROM category order by category asc") or die("Query failed: ".mysql_error());
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Dependent DropDown List</title>
<script type="text/javascript" src="http://austrianweddingaward.at/wp-content/themes/lawyerplus/js/jquery.js"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#parent_cat").change(function() {
jQuery(this).after('<div id="loader"><img src="http://www.austrianweddingaward.at/wp-content/themes/lawyerplus/img/loading.gif" alt="loading subcategory" /></div>');
jQuery.get('http://www.austrianweddingaward.at/wp-content/themes/lawyerplus/loadsubcat.php?parent_cat=' + jQuery(this).val(), function(data) {
jQuery("#sub_cat").html(data);
jQuery('#loader').slideUp(200, function() {
jQuery(this).remove();
});
});
});
});
</script>
</head>
<body>
<form method="get">
<label for="category">Hauptkategorie</label>
<select name="parent_cat" id="parent_cat">
<?php while($row = mysql_fetch_array($query_parent)): ?>
<option value="<?php echo $row['cat_id']; ?>"><?php echo $row['category']; ?></option>
<?php endwhile; ?>
</select>
<br/><br/>
<label>Unterkategorie</label>
<select name="sub_cat" id="sub_cat"></select>
</form>
</body>
</html>
Here is the content of loadsubcat.php
<?php
include('config.php');
$parent_cat = $_GET['parent_cat'];
echo $parent_cat;
mysql_query("SET CHARACTER SET 'utf8'");
$query = mysql_query("SELECT * FROM subcategory WHERE cat_id = '$parent_cat'");
echo $query;
while($row = mysql_fetch_array($query)) {
echo "<option value='$row[id]'>$row[subcategory]</option>";
}
?>
Kind Regards for any suggestions.
Stefan