I have been trying to implement a 3 chain select
on the main zen-cart page using ajax.
The script is essentially
blueicestudios.com/chained-select-boxes-using-php-mysql-ajax/
with php and mysql modifications made to meet my requirements.
I put the following code in the template html_header.php page
between the head tags.
Code:
<?php include('func.php'); ?>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#wait_1').hide();
$('#drop_1').change(function(){
$('#wait_1').show();
$('#result_1').hide();
$('#result_2').hide();
$.get("func.php", {
func: "drop_1",
drop_var: $('#drop_1').val()
}, function(response){
$('#result_1').fadeOut();
setTimeout("finishAjax('result_1', '"+escape(response)+"')", 400);
});
return false;
});
});
function finishAjax(id, response) {
$('#wait_1').hide();
$('#'+id).html(unescape(response));
$('#'+id).fadeIn();
}
function finishAjax_tier_three(id, response) {
$('#wait_2').hide();
$('#'+id).html(unescape(response));
$('#'+id).fadeIn();
}
</script>
I then put
Code:
<form action="test.php" method="get">
<select name="drop_1" id="drop_1">
<option value="" selected="selected" disabled="disabled">Select a Category</option>
<?php getTierOne(); ?>
</select>
<span id="wait_1" style="display: none;">
<img alt="Please Wait" src="ajax-loader.gif"/>
</span>
<span id="result_1" style="display: none;"></span>
<span id="wait_2" style="display: none;">
<img alt="Please Wait" src="ajax-loader.gif"/>
</span>
<span id="result_2" style="display: none;"></span>
</form>
I place the func.php in my zen-cart folder root.
When I try to load view the page it appears to stop when
it tries to stop executing at the getTierOne(); as nothing appears after that and hen I comment out that line all the usuall zen-cart
links etc.. load. The func.php files contain the sql to out the new select menus.
I think the issue I am having my be related to the func.php location on the server to where the function executes in the main page.
Bookmarks