<html>
<head>
<cfquery name="getCategories" datasource="#mydatasource#" username="#myusername#" password="#mypassword#">
SELECT catID,catTitle FROM categories WHERE type = 'cat' AND display = 'Y' ORDER BY catid
</cfquery>
<script type="text/javascript">
if (document.forms[0].type.selectedIndex == n ){
document.forms[0].parentcat.style.visibility = "visible";
}
else {
document.forms[0].parentcat.style.visibility = "hidden";
}
</script>
</head>
<body>
<cfset session.customVariable = getTickCount()>
<cfform id="newCat" action="engine.cfm" method="post" format="html">
<cfinput type="hidden" name="customVariable" value="#session.customvariable#">
<cfinput type="hidden" name="process" value="addCat">
<table cellpadding="0" cellspacing="0">
<tr>
<th colspan="2">New Category</th>
</tr>
<cfif isDefined('session.errormessage')>
<tr>
<td colspan="2"><cfoutput><span style="color:##FF0000; ">#session.errormessage#</span></cfoutput></td>
</tr>
<cfset structDelete(session,'errormessage')>
</cfif>
<tr>
<td>Category Type:</td>
<td>
<select name="type">
<option value=" "></option>
<option value="cat">Main Category</option>
<option value="sub">Sub Category</option>
</select>
</td>
</tr>
<tr>
<td>Name:</td>
<td><cfinput type="text" name="title" size="20" maxlength="100" required="yes" message="A name for the category is required."></td>
</tr>
<tr>
<td>Parent Category:</td>
<td>
<cfselect enabled="Yes" name="parentcat" multiple="no" query="getCategories" value="catid" display="cattitle" queryPosition="below">
<option value=" "></option>
</cfselect>
</td>
</tr>
<tr>
<td colspan="2"><cfinput type="submit" name="submit" value="Submit" validate="submitonce" validateat="onserver,onsubmit"></td>
</tr>
</table>
</cfform>
</body>
</html>
I want the bottom <cfselect> only to show if Sub Category is selected in the first <select> list. The javascript that I have doesn't work and I don't know javascript at all. Also I just want to know if ColdFusion can do it. I am guessing no because ColdFusion is Server-side coding.

New Topic/Question
Reply




MultiQuote




|