It works by using the an "onchange" event call in the first list box.
Code: Select all
<select name="category" id="category" onchange="getSecond(this.value);">Code: Select all
<body onload="getSecond(document.myform.category.value);">Thanks
Moderator: General Moderators
Code: Select all
<select name="category" id="category" onchange="getSecond(this.value);">Code: Select all
<body onload="getSecond(document.myform.category.value);">Code: Select all
<script type="text/javascript">
function getSecond(value) {
var url = 'sublist.php';
var myAjax = new Ajax.Request
(
url,
{
method: "post",
parameters : "catagory="+value,
onSuccess: function transResult (response) {
document.getElementById('sublist').innerHTML=response.responseText;
},
onFailure: function transResult (response) {
alert ('Failure'+response.responseText);
}
}
);
return false;
}
</script>Code: Select all
<body onload="getSecond(document.getElementById('category').value)">Code: Select all
<body onload="getSecond(document.forms.myform.category.value);">Code: Select all
<select name="category" id="category" onchange="getSecond(this.value);">
<?php
$currentcat=mysql_query("SELECT category FROM product WHERE title='$_GET[title]' AND subcat='$_GET[subcat]'");
while ($_rows=mysql_fetch_array($currentcat))
{
$_SESSION[currentcat]=$_rows[category];
echo "<option value=" .$_SESSION[currentcat].">".$_SESSION[currentcat]."</option>";
}
if ($_SESSION[existing]=='0'){
echo "<option value=''></option>";
}
$categories=mysql_query("SELECT category FROM subcat GROUP BY category");
while ($_rows=mysql_fetch_array($categories))
{
echo "<option value=" . $_rows[category] . ">" . $_rows[category] . "</option>";
}
?>
</select>