I’m building a page where users can write reviews about music/video/… I would like to build a dynamic page, that shows different options for different categories. This page would be loaded by a html dropbox. I though the Onchange option would work perfect for this.
My website is made with a template system, so my html and php are in seperate files. This should not make a big problem though. I was thinking about making the dropbox send a value to the review.php, and the php would $_GET the category and switch cases for each category. For each case, i would send a true value to the html template. Example:
if (isset($_GET['category'])){
switch($_GET['category']){
case '1' :
$reviewtpl->set("video",true,true);
break;
//and the rest of the cases...
}
}
the video part of the review template would in this case look something like this:
<if:video>
code that i want to load if video is selected in the dropbox
</if:video>
I’m pretty sure that i got my php and html part correct, the only problem seems to be the javascript function that loads the dropbox option and sends it to review.php. I got 2 functions for this:
function getHTTPObject(){
if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
else if (window.XMLHttpRequest) return new XMLHttpRequest();
else {
err_msg("Page requires javascript.");
stdfoot();
exit();
}
}
function getCategory(){
httpObject = getHTTPObject();
if (httpObject != null) {
httpObject.open("GET", "review.php?category="+document.getElementById('category').value, true);
httpObject.send(null);
}
}
I’m not very good at javascript, and these are just some functions which i found and changed to my needs. But as you may expect, they do not work. I feel like there is something missing but i’m not sure what. Would anyone know what’s missing, or know a different way of doing what i want?
PS: i hope i’m making any sense, it’s kinda hard to explain