Hi!
I'm having problems in getting the value of the selected item and showing the items in the second dropdown. When I select a category on the first menu, the choices on the second menu appears but the selected choice doesn't show in the dropdown. And i don't get the value of the selected item. How do i make the dynamic drop down work properly and get the values of the selected items in both menus so that i can use them in the next page. really need help here! thanks!
<?php
session_start();
if(!session_is_registered(myusername)){
header("Location:main_login.php");
}
?>
<html>
<head>
<title>Employee</title>
<style type="text/css">
<!--
.tableHead {
font-family: "Myriad Pro Light", "Myriad Pro";
font-size: 17px;
font-style: normal;
font-weight: bold;
color: #FFF;
}
.tableHead1 {
font-family: "Myriad Pro Light", "Myriad Pro";
font-size: 15px;
font-style: normal;
font-weight: bold;
color: #346198;
}
.tableHead2 {
font-family: "Myriad Pro Light", "Myriad Pro";
font-size: 14px;
font-style: normal;
font-weight: bold;
color: #FFF;
}
.tableContent {
font-family:Euphemia;
font-size: 13px;
font-style: normal;
color: #000;
}
-->
</style>
<script type="text/javascript">
function confSubmit(form) {
if (confirm("Are you sure you want to send this report?")) {
window.location("userMy_Asset.php")
} else {
alert("You decided to not submit the report!");
window.location("mainUser.php")
}
}
function reload(form){
var val=form.cat.options[form.cat.options.selectedIndex].value;
self.location='dd.php?cat=' + val ;
}
</script>
</script>
</head>
<body>
<table width="914" height="154" border="0">
<tr>
<td width="840" height="23" colspan="5" bgcolor="#346198" class="tableHead">Report Asset</td>
</tr>
<tr>
<td height="12" colspan="5"></td>
</tr>
<form action="userReport_Confirm.php" method="post"><tr>
<td height="83" colspan="5"><table width="501" height="115" order="0" style="text-align: center; font-weight: normal; border-collapse:collapse; border:1px solid #346198" cellpadding="3" cellspacing="3">
<tr>
<td height="21" colspan="3" class="heading4" bgcolor="#346198"><div align="left" class="tableHead">Create New Ticket</div></td>
</tr>
<tr>
<td width="84" height="27" class="heading4"><div align="left">Category:</div></td>
<td width="148"><div align="left">
<select name="category" onchange="this.form.submit()">
<option>Select a category</option>
<option value="Hardware">Hardware</option>
<option value="Software">Software</option>
</select>
</div>
</td>
<td width="206"><div align="left">
<select name="subcategory" onchange="this.form.submit()">
<option>Select a subcategory</option>
<?php
include "..\configdb.php";
include "..\opendb.php";
$category = $_POST['category'];
session_register("category");
$_SESSION['category']=$category;
if(!strcmp($_POST['category'],"Hardware")){
$id = $_SESSION['id'];
$result = mysql_query("SELECT _subcategory FROM inventory_hardware WHERE _assignedTo='$id'");
if(!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
while($row=mysql_fetch_array($result))
{
$i;
$option = $row['_subcategory'];
echo "<option value='$option'>$option</option>";
$i++;
} // end while loop
//get asset control number
$result = mysql_query("SELECT _controlNumber FROM inventory_hardware WHERE _assignedTo='$id' and _subcategory='$_POST[subcategory]'");
while($row=mysql_fetch_array($result))
{
$controlNum = $row['_controlNumber'];
}
$_SESSION['controlNum']= $controlNum;
$subcategory = $_POST['subcategory'];
session_register("subcategory");
$_SESSION['subcategory']=$subcategory;
}
if(!strcmp($_POST['category'],"Software")){
$id = $_SESSION['id'];
$result = mysql_query("SELECT _subcategory FROM inventory_software WHERE _assignedTo='$id'");
if(!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
while($row=mysql_fetch_array($result))
{
$i;
$option = $row['_subcategory'];
echo "<option value='$option'>$option</option>";
$i++;
} // end while loop
//get asset control number
$result = mysql_query("SELECT _controlNumber FROM inventory_software WHERE _assignedTo='$id' and _subcategory='$_POST[subcategory]'");
while($row=mysql_fetch_array($result))
{
$controlNum = $row['_controlNumber'];
}
$_SESSION['controlNum']= $controlNum;
$subcategory = $_POST['subcategory'];
session_register("subcategory");
$_SESSION['subcategory']=$subcategory;
}
?>
</select>
</div></td>
<?php
echo "Category is: ".$_SESSION['cat'];
echo "Sub-Category is: ".$_SESSION['subcat'];
echo "Control Number is: ".$_SESSION['controlNum'];
?>
</tr>
<tr>
<td height="11" class="heading4"><div align="left">Problem:</div></td>
<td colspan="2" rowspan="2"><div align="left"><textarea name="problem" cols="45" rows="3"></textarea></div></td>
</tr>
<tr>
<td height="11" class="heading4"> </td>
</tr>
</table></td>
</tr>
<tr>
<td width="64" height="26" class="heading4">
<input type="submit" value="Submit" />
</form>
</table>
</body>
</html>