Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

populate dropdown menues.

Status
Not open for further replies.

shawntbanks

Programmer
Oct 29, 2003
48
CA
hi there, I am relitively new to coldfusion and Javascript, so i am looking for a little help regarding dropdown menues. I seem to have no problem populating them from scratch, but when I recall what a person has selected, and put that in as the selection that shows, and then give them the option to change it, that is where I am running into problems, I cant seem to get the subcategory field to work with the category. Maybe someone has a better solution than what I am using, maybe I am going about it all the wrong way. Please help

Thanks



<cfset idx = -1>
<cfset mycase = 0>
<head>
<title>Online Shopping Centre</title>




<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--
// BannerAD

var bannerAD=new Array();
var bannerADlink=new Array();
var adNum=0;

<cfinclude template = &quot;banneradssecondlevel_dirs.cfm&quot;>
var preloadedimages=new Array();
for (i=1;i<bannerAD.length;i++){
preloadedimages=new Image();
preloadedimages.src=bannerAD;
}

function setTransition(){
if (document.all){
bannerADrotator.filters.revealTrans.Transition=Math.floor(Math.random()*23);
bannerADrotator.filters.revealTrans.apply();
}
}

function playTransition(){
if (document.all)
bannerADrotator.filters.revealTrans.play()
}

function nextAd(){
if(adNum<bannerAD.length-1)adNum++ ;
else adNum=0;
setTransition();
document.images.bannerADrotator.src=bannerAD[adNum];
playTransition();
theTimer=setTimeout(&quot;nextAd()&quot;, 10000);
}

function jump2url(){
jumpUrl=bannerADlink[adNum];
jumpTarget='_blank';
if (jumpUrl != ''){
if (jumpTarget != '')window.open(jumpUrl,jumpTarget);
else location.href=jumpUrl;
}
}
function displayStatusMsg() {
status=bannerADlink[adNum];
document.returnValue = true;
}

function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a.indexOf(&quot;#&quot;)!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}}
}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf(&quot;?&quot;))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//-->
function whichLocal(obj){
switch (obj.select_Ad_Subcategory.selectedIndex){
<!--- use the group attribute to group output by category --->
<cfoutput query=&quot;get_SubCategories&quot; group=&quot;Category&quot;>
<cfset mycase = mycase + 1>case #mycase#:
<cfset myList = ValueList(get_SubCategories.categoryid)>
<cfset numberInCategory = ListValueCount(myList, categoryid)>
obj.selectLocal.length=#numberInCategory#<cfoutput><cfset idx = idx + 1>
obj.selectLocal.options[#idx#].value=&quot;#get_SubCategories.subcategoryid#&quot;
obj.selectLocal.options[#idx#].text=&quot;#trim(get_SubCategories.SubCategory)#&quot;</cfoutput>
break;

<cfset idx = -1>
</cfoutput>
}
}

</script>

</head>
<center>
<body bgcolor=7B755A link=&quot;7B755A&quot; vlink=&quot;339933&quot; alink=&quot;A8A586&quot; onLoad=&quot;MM_preloadImages('../images/Vehicle_on.jpg','../images/Real_Estate_on.jpg')&quot;>
<table width=&quot;760&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>

<!--- Top table begins here --------------------------------------------------------------------------->

<table width=&quot;760&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<tr>
<td valign=&quot;top&quot;><img src=&quot;../images/market_logo.gif&quot;></td>
<td valign=&quot;top&quot;>
<table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; bgcolor=&quot;A6A586&quot;>
<tr>
<td colspan=&quot;3&quot;><img src=&quot;../images/top_space.gif&quot;></td>
</tr>
<tr height=&quot;60&quot;>
<td><a href=&quot;javascript:jump2url()&quot; onMouseOver=&quot;displayStatusMsg();return document.returnValue&quot;><img src=&quot;../images/image1.gif&quot; name=&quot;bannerADrotator&quot; style=&quot;filter:revealTrans(duration=2,transition=20)&quot; border=0></a>
<script language=&quot;JavaScript&quot;>nextAd()</script></td>
</tr>
<tr>
<cfif Not isdefined (&quot;browser&quot;)><td colspan=&quot;3&quot;><img src=&quot;../images/bottom_spacer2.gif&quot;></td><cfelse><td colspan=&quot;3&quot;><img src=&quot;../images/bottom_spacer.gif&quot;></td></cfif>
</tr>
</table>

</td>
<td align=&quot;top&quot;><img src=&quot;../images/town_logo.gif&quot;></td>
</table>

<!--- Top table ends here -------------------------------------------------------------------------->

<td width=&quot;760&quot;></td></tr>
<tr><td align=&quot;top&quot;><table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; width=&quot;760&quot;>
<tr>
<td width=&quot;158&quot; valign=&quot;top&quot; background=&quot;../images/top_space2.gif&quot;>
<img src=&quot;../images/top_space2.gif&quot;><br>
<img src=&quot;../images/contents.gif&quot;><br>
<a href=&quot;../home.cfm&quot; onMouseOut=&quot;MM_swapImgRestore()&quot; onMouseOver=&quot;MM_swapImage('Image36','','../Images/home_on.gif',1)&quot;><img border=0 src=&quot;../images/home.gif&quot; name=&quot;Image36&quot;></a><br>
<a href=&quot;../place_ad.cfm&quot; onMouseOut=&quot;MM_swapImgRestore()&quot; onMouseOver=&quot;MM_swapImage('Image37','','../Images/placeanad_on.gif',1)&quot;><img border=0 src=&quot;../images/placeanad.gif&quot; name=&quot;Image37&quot;></a><br>
<a href=&quot;../Registration.cfm&quot; onMouseOut=&quot;MM_swapImgRestore()&quot; onMouseOver=&quot;MM_swapImage('Image38','','../Images/register_on.gif',1)&quot;><img border=0 src=&quot;../images/register.gif&quot; name=&quot;Image38&quot;></a><br>
<a href=&quot;../Services_and_howto.cfm&quot; onMouseOut=&quot;MM_swapImgRestore()&quot; onMouseOver=&quot;MM_swapImage('Image39','','../Images/Contents_services_on.gif',1)&quot;><img border=0 src=&quot;../images/Contents_Services.gif&quot; name=&quot;Image39&quot;></a><br>
<a href=&quot;../FAQ.cfm&quot; onMouseOut=&quot;MM_swapImgRestore()&quot; onMouseOver=&quot;MM_swapImage('Image40','','../Images/faq_on.gif',1)&quot;><img border=0 src=&quot;../images/faq.gif&quot; name=&quot;Image40&quot;></a><br>
<a href=&quot;../Contact_Us.cfm&quot; onMouseOut=&quot;MM_swapImgRestore()&quot; onMouseOver=&quot;MM_swapImage('Image41','','../Images/contact_on.gif',1)&quot;><img border=0 src=&quot;../images/contact.gif&quot; name=&quot;Image41&quot;></a><br>
<img src=&quot;../images/categories.gif&quot;><br>
<a href=&quot;../Ad_Drill_Down.cfm?id=2&quot; onMouseOut=&quot;MM_swapImgRestore()&quot; onMouseOver=&quot;MM_swapImage('Image28','','../images/Vehicle_on.gif',1)&quot;><img src=&quot;../images/Vehicles.gif&quot; name=&quot;Image28&quot; width=&quot;158&quot; height=&quot;17&quot; border=&quot;0&quot;></a><br>
<a href=&quot;../Ad_Drill_Down.cfm?id=3&quot; onMouseOut=&quot;MM_swapImgRestore()&quot; onMouseOver=&quot;MM_swapImage('Image35','','../images/RealEstate_on.gif',1)&quot;><img src=&quot;../images/realestate.gif&quot; name=&quot;Image35&quot; width=&quot;158&quot; height=&quot;16&quot; border=&quot;0&quot;></a><br>
<a href=&quot;../Ad_Drill_Down.cfm?id=14&quot; onMouseOut=&quot;MM_swapImgRestore()&quot; onMouseOver=&quot;MM_swapImage('Image30','','../images/rentals_on.gif',1)&quot;><img border=0 src=&quot;../images/rentals.gif&quot; name=&quot;Image30&quot; width=&quot;158&quot; height=&quot;16&quot;></a><br>
<a href=&quot;../Ad_Drill_Down.cfm?id=15&quot; onMouseOut=&quot;MM_swapImgRestore()&quot; onMouseOver=&quot;MM_swapImage('Image31','','../images/Merchandise_on.gif',1)&quot;><img border=0 src=&quot;../images/merchandise.gif&quot; name=&quot;Image31&quot; width=&quot;158&quot; height=&quot;16&quot;></a><br>
<a href=&quot;../Ad_Drill_Down.cfm?id=1&quot; onMouseOut=&quot;MM_swapImgRestore()&quot; onMouseOver=&quot;MM_swapImage('Image32','','../images/Electronics_on.gif',1)&quot;><img border=0 src=&quot;../images/electronics.gif&quot; name=&quot;Image32&quot; width=&quot;158&quot; height=&quot;17&quot;></a><br>
<a href=&quot;../Ad_Drill_Down.cfm?id=16&quot; onMouseOut=&quot;MM_swapImgRestore()&quot; onMouseOver=&quot;MM_swapImage('Image33','','../images/Services_on.gif',1)&quot;><img border=0 src=&quot;../images/services.gif&quot; name=&quot;Image33&quot; width=&quot;158&quot; height=&quot;17&quot;></a><br>
<a href=&quot;../Ad_Drill_Down.cfm?id=17&quot; onMouseOut=&quot;MM_swapImgRestore()&quot; onMouseOver=&quot;MM_swapImage('Image34','','../images/Equipment_on.gif',1)&quot;><img border=0 src=&quot;../images/equipment.gif&quot; name=&quot;Image34&quot; width=&quot;158&quot; height=&quot;17&quot;></a><br>
<img src=&quot;../images/dot_space.gif&quot;>
<table>
<!--- <img src=&quot;../Images/search.gif&quot;> --->
<tr><td><div align=&quot;center&quot;><font face=&quot;Georgia, Times New Roman, Times, serif&quot;><strong>Advanced<br>
Search</strong></font></div></td></tr>
<tr>
<td valign=&quot;middle&quot; height=&quot;50&quot;>
<cfform action=&quot;../cat_Search.cfm&quot; method=&quot;post&quot;>
<cfinput size=&quot;15&quot; type=&quot;text&quot; name=&quot;Item_Name&quot;>

<input name=&quot;Submit&quot; type=&quot;image&quot; src=&quot;../images/go.gif&quot; alt=&quot;Search&quot; align=&quot;bottom&quot;>
</cfform></td></tr></table>




</td>


Page 2
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>
<html>
<cfquery name=&quot;get_Communities&quot; datasource=&quot;Market&quot;>
SELECT *
FROM Communities
order by location
</cfquery>

<cfquery name=&quot;get_SubCategories&quot; datasource=&quot;Market&quot;>
SELECT Category, categoryid, subcategory, subcategoryid
FROM subandcat

</cfquery>
<cfinclude template=&quot;../Templates/Header_&_Sidebar_for_Place_Ad_Folder_Subcat_Select.cfm&quot;>
<td width=&quot;603&quot; rowspan=&quot;2&quot; valign=&quot;top&quot; bgcolor=&quot;#FFFFFF&quot;>
<CFIF IsDefined(&quot;FORM.edititemnum&quot;)>

<CFLOCK timeout=&quot;30&quot;
throwontimeout=&quot;no&quot;
type=&quot;exclusive&quot;
scope=&quot;session&quot;>
<CFSET SESSION.cart[#FORM.edititemnum#].itemname = FORM.itemname>
<CFSET SESSION.cart[#FORM.edititemnum#].categoryid = FORM.select_Ad_Subcategory>
<CFSET SESSION.cart[#FORM.edititemnum#].subcategoryid = FORM.selectLocal>
<CFSET SESSION.cart[#FORM.edititemnum#].location = FORM.Community_List>
<CFSET SESSION.cart[#FORM.edititemnum#].Short_Description = FORM.Short_Description>
<CFSET SESSION.cart[#FORM.edititemnum#].long_description = FORM.long_description>
<CFSET SESSION.cart[#FORM.edititemnum#].itemprice = FORM.itemprice>
<CFSET SESSION.cart[#FORM.edititemnum#].featured = FORM.featured>
<CFSET SESSION.cart[#FORM.edititemnum#].begindate = FORM.begindate>
<CFSET SESSION.cart[#FORM.edititemnum#].enddate = FORM.begindate + FORM.enddate>


</CFLOCK>
<!--- maybe to a CFLOCATION back to page3 here, if you want --->
<cflocation url=&quot;step3.cfm&quot;>
<CFELSE>

<CFSET strEditItem = StructNew()>
<CFLOCK timeout=&quot;30&quot;
throwontimeout=&quot;no&quot;
type=&quot;readonly&quot;
scope=&quot;session&quot;>
<CFSET strEditItem = SESSION.cart[#URL.itemnum#]>
</CFLOCK>
<!---<cfif isdefined (&quot;url.itemnum&quot;)></cfif> --->
<cfquery name=&quot;get_cat&quot; datasource=&quot;Market&quot;>
SELECT Category, categoryid, subcategory, subcategoryid
FROM subandcat
where subcategoryid = #SESSION.cart[URL.itemnum].subcategoryid#
</cfquery>
<cfquery name=&quot;get_subcat2&quot; datasource=&quot;Market&quot;>
SELECT Category, categoryid, subcategory, subcategoryid
FROM subandcat
where categoryid = #get_cat.categoryid#
</cfquery>

<cfform action=&quot;edit_item.cfm&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;>

<table align=&quot;center&quot; border=&quot;0&quot;>
<tr>
<td colspan=&quot;5&quot; class=&quot;FormHeaders&quot;><div align=&quot;center&quot;><font size=&quot;4&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;><!--- <cfoutput>#categories.Category#</cfoutput> --->
Details</font></div></td>
</tr>
<tr bgcolor=&quot;#EDECE0&quot;><td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Category:</font></td>
<td valign=&quot;top&quot; colspan=&quot;4&quot;>
<!---<select name=&quot;select_Ad_Subcategory&quot; onchange=&quot;whichLocal(this.form)&quot; size=&quot;1&quot;>
<cfoutput><option value=&quot;#get_cat.categoryid#&quot;>#get_cat.category#</option></cfoutput>
again, use the group attribute to group output by category
<cfoutput query=&quot;get_SubCategories&quot; group=&quot;Category&quot;>
<option value=&quot;#Categoryid#&quot;>#Category#</option>
</cfoutput>

<cfoutput query=&quot;get_SubCategories&quot; group=&quot;Category&quot;>
<option value=&quot;#Categoryid#&quot; <cfif get_cat.categoryid eq get_subCategories.categoryid> selected</cfif>>#Category#</option>
</cfoutput>
</select>--->
<select name=&quot;select_Ad_Subcategory&quot; onchange=&quot;whichLocal(this.form)&quot; size=&quot;1&quot;>
<cfoutput query=&quot;get_SubCategories&quot; group=&quot;Category&quot;>
<option value=&quot;#Categoryid#&quot; <cfif get_cat.categoryid eq get_subCategories.categoryid> selected</cfif>>#Category#</option>
</cfoutput>
</select>



</td></tr>
<tr><td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Subcategory:</font></td>
<td colspan=&quot;4&quot;> <!--- <select name=&quot;selectLocal&quot; onChange=&quot;whichLocal(this.form)&quot; size=&quot;1&quot;>
<cfoutput><option value=&quot;#get_cat.subcategoryid#&quot;>#get_cat.subcategory#</option></cfoutput>
<cfoutput query=&quot;get_subcat2&quot;><option value=&quot;#subcategory#&quot;>#subcategory#</option></cfoutput> --->
<select name=&quot;selectLocal&quot; onChange=&quot;whichLocal(this.form)&quot; size=&quot;1&quot;>
<cfoutput query=&quot;get_subcat2&quot;><option value=&quot;#subcategory#&quot; <cfif get_cat.subcategoryid eq get_subcat2.subcategoryid>selected</cfif>>#subcategory#</option></cfoutput>
</select>
<!---<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
</select>---></td>
</tr>


<tr bgcolor=&quot;#EDECE0&quot;>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Community:</font></td>
<td colspan=&quot;4&quot;><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>
<select name=&quot;Community_List&quot;>

<option><cfoutput>#strEditItem.location#</cfoutput></option>
<cfoutput query=&quot;Get_Communities&quot;>
<option value=&quot;#location#&quot;>#location#</option>
</cfoutput>
</select>
</font></td>
</tr>
<tr>
<td width=&quot;109&quot; ><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Item
Name:</font></td>
<td colspan=&quot;4&quot;> <font face=&quot;Georgia, Times New Roman, Times, serif&quot;>

<CFinput name=&quot;Itemname&quot; type=&quot;text&quot; required=&quot;no&quot; message=&quot;Item Name Required&quot; value=&quot;#strEditItem.itemname#&quot;>
</font></td>
</tr>
<tr bgcolor=&quot;#EDECE0&quot;>
<td valign=&quot;top&quot; ><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Short
Description:</font></td>
<td colspan=&quot;4&quot;>
<textarea name=&quot;Short_description&quot; cols=&quot;30&quot; rows=&quot;5&quot; wrap=&quot;hard&quot; onChange=&quot;if (this.value.length > 100) {alert('The Short Description Cannot Be Greater Than 100 Chars.')};&quot;><cfoutput>#strEditItem.short_description#</cfoutput></textarea>

</td>
</tr>
<tr>
<td valign=&quot;top&quot; ><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Long
Description:</font></td>
<td colspan=&quot;4&quot;><textarea name=&quot;Long_description&quot; cols=&quot;30&quot; rows=&quot;5&quot;><cfoutput>#strEditItem.long_description#</cfoutput></textarea>

</td>
</tr>
<tr bgcolor=&quot;#EDECE0&quot;>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Asking
Price:</font></td>
<td colspan=&quot;4&quot;><CFinput name=&quot;itemprice&quot; value=&quot;#strEditItem.itemprice#&quot; type=&quot;text&quot; id=&quot;itemprice&quot; required=&quot;no&quot; message=&quot;Asking Price Required&quot; size=&quot;20&quot; maxlength=&quot;9&quot;>

</td>
</tr>
<tr>
<td valign=&quot;top&quot;><font face=&quot;Georgia, Times New Roman, Times, serif&quot;><span >Featured
Item</span><font color=&quot;#FF0000&quot;>*</font></font></td>
<td colspan=&quot;4&quot;> <cfif strEditItem.Featured EQ 1><CFinput name=&quot;featured&quot; type=&quot;radio&quot; id=&quot;featured&quot; value=&quot;1&quot;checked=&quot;yes&quot;> <cfelse><CFinput name=&quot;featured&quot; type=&quot;radio&quot; id=&quot;featured&quot; value=&quot;1&quot;></cfif>
<font size=&quot;-2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>Yes</font> </td>
<tr><td> </td><td colspan=&quot;4&quot;> <cfif strEditItem.Featured EQ 0><CFinput name=&quot;featured&quot; type=&quot;radio&quot; id=&quot;featured&quot; value=&quot;0&quot; checked=&quot;yes&quot;> <cfelse><CFinput name=&quot;featured&quot; type=&quot;radio&quot; id=&quot;featured&quot; value=&quot;0&quot;></cfif>
<font size=&quot;-2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>No</font> </td></tr>
</tr>
<tr bgcolor=&quot;#EDECE0&quot;>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Start
Date Of Ad:</font></td>
<td colspan=&quot;4&quot;><cfinput name=&quot;begindate&quot; type=&quot;text&quot; validate=&quot;date&quot; value=&quot;#strEditItem.begindate#&quot;>
</td>
</tr>
<tr>
<td valign=&quot;top&quot;><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Length
Of Ad:</font></td>
<td><cfif strEditItem.Enddate EQ strEditItem.begindate + 7><CFinput name=&quot;Enddate&quot; type=&quot;radio&quot; value=&quot;7&quot; checked=&quot;yes&quot;><cfelse><CFinput name=&quot;Enddate&quot; type=&quot;radio&quot; value=&quot;7&quot;></cfif></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>7
Days</font></td>
<tr bgcolor=&quot;#EDECE0&quot;>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;> </font></td>
<td><cfif strEditItem.Enddate EQ strEditItem.begindate + 30><CFinput name=&quot;Enddate&quot; type=&quot;radio&quot; value=&quot;30&quot; checked=&quot;yes&quot;><cfelse><CFinput name=&quot;Enddate&quot; type=&quot;radio&quot; value=&quot;30&quot;></cfif></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>30 Days
</font></td>
</tr></table>

<table align=&quot;center&quot; border=&quot;0&quot;>

<tr bgcolor=&quot;#FFFFFF&quot;>
<td colspan=&quot;5&quot;><div align=&quot;center&quot;> <CFOUTPUT><input type=&quot;hidden&quot; name=&quot;edititemnum&quot; value=&quot;#URL.itemnum#&quot;></CFOUTPUT>
<input type=&quot;submit&quot; value=&quot;Continue >>&quot;>
</div></td>
</tr>
</table>


</cfform>

</CFIF>

<tr>
<td background=&quot;../images/top_space2.gif&quot;><img src=&quot;../images/top_space2.gif&quot;></td>
</tr>
</table>
</td></tr>
</table>

</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top