Conditional Dropdown Boxes in Front-End
Posted: Thu Mar 21, 2013 3:21 pm
Hi guys.
THIS IS A CONTINUATION OF THIS THREAD. To better emphasize the difference between front and back end, separate threads have been created.
THIS THREAD IS RELATED TO PROVIDING CUSTOMERS WITH CONDITIONAL DROPDOWN BOXES.
IF YOU'RE TRYING TO ADD DROPDOWNS TO THE ADMIN AREA PLEASE VIEW THIS THREAD INSTEAD.
While I'm at it, perhaps someone could assist me with my own issues
Ever since I upgraded I can't seem to get the dropdown for my sub-cats to work. The first set "category" works fine but the second "sub-category" lists the box and contains "Select SubCategory" but doesn't list any of the options. Here's the relevant part of the index.php:
as always, thanks in advance.
Phil
THIS IS A CONTINUATION OF THIS THREAD. To better emphasize the difference between front and back end, separate threads have been created.
THIS THREAD IS RELATED TO PROVIDING CUSTOMERS WITH CONDITIONAL DROPDOWN BOXES.
IF YOU'RE TRYING TO ADD DROPDOWNS TO THE ADMIN AREA PLEASE VIEW THIS THREAD INSTEAD.
While I'm at it, perhaps someone could assist me with my own issues

Ever since I upgraded I can't seem to get the dropdown for my sub-cats to work. The first set "category" works fine but the second "sub-category" lists the box and contains "Select SubCategory" but doesn't list any of the options. Here's the relevant part of the index.php:
Code: Select all
<table border="0" width="100%">
<tr>
<td style="text-align:right" width="150"><?php echo $hesklang['category']; ?>: <font class="important">*</font></td>
<td width="80%"><select name="category" onchange="javascript: dropdownlist(this.options[this.selectedIndex].value);"<?php if (in_array('category',$_SESSION['iserror'])) {echo ' class="isError" ';} elseif (in_array('category',$_SESSION['isnotice'])) {echo ' class="isNotice" ';} ?> >
<option value="">-- Please select --</option>
<?php
if (!empty($_GET['catid']))
{
$_SESSION['c_category'] = intval($_GET['catid']);
}
while ($row = hesk_dbFetchAssoc($res))
{
$selected = (isset($_SESSION['c_category']) && $_SESSION['c_category'] == $row['id']) ? ' selected="selected"' : '';
echo '<option value="'.$row['id'].'"'.$selected.'>'.$row['name'].'</option>';
}
?>
</select></td>
</tr>
<?php
}
/* Can customer assign urgency? */
if ($hesk_settings['cust_urgency'])
{
if (!$is_table)
{
echo '<table border="0" width="100%">';
$is_table = 1;
}
?>
<tr>
<td style="text-align:right" width="150"><?php echo $hesklang['priority']; ?>: <font class="important">*</font></td>
<td width="80%"><select name="priority" <?php if (in_array('priority',$_SESSION['iserror'])) {echo ' class="isError" ';} ?> >
<option value="3" <?php if(isset($_SESSION['c_priority']) && $_SESSION['c_priority']==3) {echo 'selected="selected"';} ?>><?php echo $hesklang['low']; ?></option>
<option value="2" <?php if(isset($_SESSION['c_priority']) && $_SESSION['c_priority']==2) {echo 'selected="selected"';} ?>><?php echo $hesklang['medium']; ?></option>
<option value="1" <?php if(isset($_SESSION['c_priority']) && $_SESSION['c_priority']==1) {echo 'selected="selected"';} ?>><?php echo $hesklang['high']; ?></option>
</select></td>
</tr>
<?php
}
/* Need to close the table? */
if ($is_table)
{
echo '</table> <hr />';
}
?>
<script language="javascript" type="text/javascript">
function dropdownlist(listindex)
{
document.form1.subcategory.options.length = 0;
switch (listindex)
{
case "1" :
document.form1.subcategory.options[0]=new Option("Select Sub-Category","");
document.form1.subcategory.options[1]=new Option("a physical computer issue","a physical computer issue"); /*hardware*/
document.form1.subcategory.options[2]=new Option("a program","a program"); /*software*/
document.form1.subcategory.options[3]=new Option("accessing a company resource","accessing a company resource");
document.form1.subcategory.options[4]=new Option("accessing an internet resource","accessing an internet resource");
document.form1.subcategory.options[5]=new Option("iPhone","iPhone");
document.form1.subcategory.options[6]=new Option("iPad","iPad");
document.form1.subcategory.options[7]=new Option("BlackBerry Phone","BlackBerry Phone");
document.form1.subcategory.options[8]=new Option("BlackBerry PlayBook","BlackBerry PlayBook");
document.form1.subcategory.options[9]=new Option("a miscellaneous issue","a miscellaneous issue");
break;
case "9" :
document.form1.subcategory.options[0]=new Option("Select Sub-Category","");
document.form1.subcategory.options[1]=new Option("a new staff member","a new staff member");
document.form1.subcategory.options[2]=new Option("purchasing a new computer","purchasing a new computer");
document.form1.subcategory.options[3]=new Option("renewal of a program license","renewal of a program license");
document.form1.subcategory.options[4]=new Option("something else...","something else");
break;
}
return true;
}
</script>
</head>
<title>Dynamic Drop Down List</title>
<body>
<form id="form1" name="form1" method="post" action="submitform1.asp" >
<table width="100%" border="0" >
<tr>
<td style="text-align:right" width="150">Sub Category:
</td>
<td width="80%"><script type="text/javascript" language="JavaScript">
document.write('<select name="subcategory"><option value="">Select Sub-Category</option></select>')
</script>
<noscript><select name="subcategory" id="subcategory" >
<option value="">Select Sub-Category</option>
</select>
</noscript></td>
</tr>
</table>
</form>
Phil