I have a question regarding ajax, I have a category drop down box and some javascript in place so that when the user selects a category, this automatically redirects the page to that category without having to click a submit button. My question is simple, how can I add ajax to this process to stop the page load and just load the div with the category items?
I am using expression engine cms, which I know doesn’t matter but the tags are in the code.
This is my code:
<script language="JavaScript" type="text/javascript">
var theTarget = "_top";
function goThere() {
if (!document.theForm.theMenu.selectedIndex=="") {
window.open(document.theForm.theMenu.options[document.theForm.theMenu.selectedIndex].value, theTarget,"");
}
}
</script>
<form name="theForm" action="">
<select name="theMenu" size="1" onchange="goThere()">
{exp:channel:categories channel="store" style="linear" category_group="1"}
<option value="{path='store-directory'}">{category_name}</option>
{/exp:channel:categories}
</select>
</form>
1 Answer