Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 195
  • Last Modified:

Search Tab

Hi,

I have three tabs menu.

Search by State
Search by City
Search by Church

when the user select the criteria from Search by State.  I need them to be able to save the selected criteria instead of selected again.

here's what I have
<script>



function getSelOptions(theRequest,theTarget){
  var xmlhttp;
  if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
  } else {// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  theRequest=theRequest+"&t="+(new Date()).getTime();
  xmlhttp.open("GET",theRequest,false);
  xmlhttp.send();
  newOpt=eval(xmlhttp.responseText);
  var opt = theTarget.options;
  opt.length=0;

if(theTarget.name == "GetCityCT") {
  opt[0] = new Option("Select a City","");
}
else if(theTarget.name == "GetCity") {
  opt[0] = new Option("Select a City","");
}
else {
  opt[0] = new Option("Select a church","");
}

  for(var i=0;i<newOpt.length;i++){
    opt[opt.length] = new Option(newOpt[i][1],newOpt[i][0]);
  }
} 


function setCityOptionsCT(theSel,fldNameFilter,fldNameTarget){
  
if(theSel.options[theSel.selectedIndex].value == "")
{
 var theForm = theSel.form;
 theForm[fldNameTarget].options.length=0;
}
else
{
  var theForm = theSel.form;
  theForm[fldNameTarget].options.length=0;
 var theFilter = escape(theForm[fldNameFilter].value.replace(/(^\s*|\s*$)/g,""));
  var theRequest = 'getOptCityName.cfm?selval='+theSel.value+'&filter='+theFilter;
  getSelOptions(theRequest,theForm[fldNameTarget]);
}
} 






function setCityOptions(theSel,fldNameFilter,fldNameTarget,fldNameTargetChild){
  
if(theSel.options[theSel.selectedIndex].value == "")
{
 var theForm = theSel.form;
  theForm[fldNameTarget].options.length=0;
  theForm[fldNameTargetChild].options.length=0;
}
else
{
  var theForm = theSel.form;
  theForm[fldNameTarget].options.length=0;
  theForm[fldNameTargetChild].options.length=0;
 var theFilter = escape(theForm[fldNameFilter].value.replace(/(^\s*|\s*$)/g,""));
  var theRequest = 'getOptCityName.cfm?selval='+theSel.value+'&filter='+theFilter;
  getSelOptions(theRequest,theForm[fldNameTarget]);
}
} 


function setChurchOptions(theSel,fldNameFilter,fldNameTarget){
  var theForm = theSel.form;
  theForm[fldNameTarget].options.length=0;
  var theFilter = escape(theForm[fldNameFilter].value.replace(/(^\s*|\s*$)/g,""));
  var theRequest = 'getOptChurchName.cfm?selval='+theSel.value+'&filter='+theFilter;
  getSelOptions(theRequest,theForm[fldNameTarget]);
}



function setStateOptions(theFilter,fldNameTarget){
  var theForm = theFilter.form;
  var opt = theForm[fldNameTarget].options;
  var rxFilter = new RegExp("^"+theFilter.value,"i");
  opt.length = 0;
  var j = 1;
  opt[0] = new Option('Select a state', '');
  for(var i=0;i<arrStates.length;i++){
    if(arrStates[i][1].match(rxFilter)){
	  opt[j] = new Option(arrStates[i][1],arrStates[i][0]);
           j = j + 1;
	}
  }
} 






//function SelectedChurchOPT(theFilter,fldIdTarget){

//self.location.href='post.cfm?chid=' + theFilter.value ;

//}

</script>

Open in new window

0
lulu50
Asked:
lulu50
  • 9
  • 5
1 Solution
 
Gurvinder Pal SinghCommented:
So you want to save the state, city and church values if they are selected from select box, even if the page is reloaded?
0
 
lulu50Author Commented:
yes
0
 
lulu50Author Commented:
In "Search by state" tab I only need to reselect "Select category"

right now when I select select "select category" than "Select type of posting" the page get reload and my previous selection to select type of post is gone.  I have to go back onchange the selection in my select category so, it can repopulate the data for select type of posting.  


<select name="SelSTPost" size="1" style="width: 180px;"
		onchange="setOptions(this.options[this.selectedIndex].value);"/>
	<cfif  (isdefined('FORM.SelSTPost')) AND (#FORM.SelSTPost# eq #DispMainMenu.MenuID#)>
		<option value="" >Select type of posting</option>
	<cfelse>
		<option value="" selected="selected">Select type of posting</option>
	</cfif>
		<cfoutput query="DispMainMenu">
		<cfif  (isdefined('FORM.SelSTPost')) AND (#FORM.SelSTPost# eq #DispMainMenu.MenuID#)>
		<option value="#DispMainMenu.MenuID#" selected="selected">#DispMainMenu.MainMenuName#</option>
		<cfelse>
		<option value="#DispMainMenu.MenuID#" >#DispMainMenu.MainMenuName#</option>
		</cfif>
		</cfoutput>
	</select>
	<select name="SelCatg" size="1" style="width: 180px;"/>
			<option value="" selected="selected">Select category</option>	
	</select>


________________________________________________

function setOptions(chosen) {
var selbox = document.FRMAcc.SelCatg;
var getmySubCat = '<cfoutput>#myList#</cfoutput>';
var CTDataList = getmySubCat.split(",");

   selbox.options.length = 0;
   if (chosen == " " || chosen != "Select All") {  
   selbox.options[selbox.options.length] = new Option('Select category',' ');
   }

   for(var i=0, limit=CTDataList.length; i<limit; i+=3)  
if (chosen == CTDataList[i]) {
  selbox.options[selbox.options.length] = new
Option(CTDataList[i+2],CTDataList[i+1]);
}

}

Open in new window

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
lulu50Author Commented:
I've requested that this question be deleted for the following reason:

I am not getting any help
0
 
Gurvinder Pal SinghCommented:
Apologies for late reply.
But i have already suggested you in my previous questions about using cookie to remember the selections made by the user. Why have we not tried that options till now? Let me know if some example is required.
0
 
lulu50Author Commented:
gurvinder372:

I am working with my menu that says (search by state) the user select the criteria than click on submit
all the criteria return back expect the drop drown box for the category.  

the category is populated from the type of post drop down list.


please, take a look at my code


my form get submitted every time the user click on Search (Search by state).  
so, instead of a using a cookie I can say

document.FRMAcc.SelCatg.value to get the value

so, in my code somewhere I have to say if the document.FRMAcc.SelCatg.value is not null
then select the value that match and list the rest of the list.


here I have to somewhere say if the 

document.FRMAcc.SelCatg.value value is not null then selected

I don't know how to do it??

function setOptions(chosen) {
var selbox = document.FRMAcc.SelCatg;
var getmySubCat = '3,2,<h1>Churches Bulletin <br>Chat Room</h1>,6,5,Accounting/Finance,2,1,Activities,6,85,Admin,7,164,Advertising,7,165,Animal Care,2,158,Announcements,4,233,Antiques,5,208,Apartment Rentals,4,234,Appliances,6,86,Architect,6,87,Art,2,27,Artists,4,235,Arts/Crafts,4,236,Auto Parts,7,166,Automotive,7,169,Baby Sitting,4,237,Barter,7,167,Beauty & Salon,4,238,Beauty/Health Care,4,239,Bikes,6,88,Biotech,4,240,Boats,4,241,Books,5,209,Building Lot,4,242,Business,6,89,Business,7,168,Car Dealers,4,243,Cars/Trucks,7,170,Catering,4,244,CDS/DVD/VHS,4,245,Cell Phones,2,28,Childcare,2,39,Classes,7,171,Cleaning,4,246,Clothes/Acc,5,211,Co-op Unit,4,247,Collectibles,7,172,Colledge Activities,2,159,College Age,4,248,Computer,5,210,Condominium Unit,7,173,Construction,7,174,Cook,6,90,Craft,7,175,Creative,6,91,Customer service,6,92,Design,5,212,Duplex,6,93,Editing,6,94,Education,7,176,Education,2,269,Elderly,7,177,Elderly Activities,7,178,Elderly Care,7,179,Electrician,4,249,Electronics,6,95,Engineering,7,180,Erotic,2,32,Events,5,213,Farm,4,250,Farm/Garden,7,181,Farm/Garden,7,182,Fast Food Chains,6,96,Film,7,183,Financial,6,97,Fitness,6,98,Food,4,251,Free,7,184,Free fast food delivery,2,155,Free Stuff,4,252,Furniture,4,253,Garage Sale,2,29,General,4,254,General,2,157,General Entertainment,6,99,General labor,6,100,Government,2,30,Groups,6,101,Health,7,185,Health & Wellness,7,186,Home,5,214,Home Rentals,6,102,Hospital,4,255,Household,7,187,Household,5,215,Housing swap,6,103,Human resources,7,188,Insurance,6,104,Internet engineers,2,156,Items Wanted,4,256,Jewelry,2,268,Kids,7,189,Kids Activities,7,190,Labor,7,191,Lawn & Garden,7,192,Legal,6,105,Legal,7,193,Lessons,2,35,Local news,2,33,Lost & Found,6,109,Management,6,106,Manufacturing,6,107,Marketing,4,257,Materials,6,108,Media,2,160,Men,5,216,Mobile/Manufactured Home,4,258,Motorcycles,7,194,Moving & Storage,5,217,Multi-Family Home,4,259,Music Instr,2,34,Musicians,6,110,Network,5,218,New Construction,6,111,Nonprofit sector,7,195,Office,6,112,Office,5,219,Offie/Commercial,5,220,Other Real Estate,7,196,Paint,6,114,Paralegal,5,221,Parking/Storage,7,197,Pet,2,31,Pets,4,260,Photo/Video,7,198,Plummer,2,36,Politics,2,153,Preschoolers,5,222,Raw Land,7,199,Real Estate,6,115,Real Estate,7,200,Rental,6,116,Retail,5,223,Room Wanted,5,224,Roommates,5,225,Rooms/Shared,5,226,Row House,4,261,RVS,6,117,Sales,6,118,Salon,6,119,Science,6,120,Security,5,227,Single Family Home,6,121,Skilled trade,7,201,Skill`d trade,6,122,Software,4,262,Sporting,7,202,Sports,5,228,Sublets/Temporary,6,123,Technical support,2,161,The Gathering Place,4,263,Tickets,5,229,Time Share,4,264,Tools,5,230,Townhouse/Townhome,4,265,Toys/Games,7,203,Training & Education,6,124,Transport,7,204,Travel,6,125,Tv,5,231,Vacation Rentals,5,232,Vacation swap,6,126,Video,4,266,Video Gaming,2,38,Volunteers,4,267,Wanted,6,127,Web design,7,205,Web Design & Tech,7,206,Wedding & Photography,2,154,Weekly Information,6,128,Wholesale,2,152,Women,7,207,Writer,6,129,Writing';
var CTDataList = getmySubCat.split(",");

   selbox.options.length = 0;
   if (chosen == " " || chosen != "Select All") {  
   selbox.options[selbox.options.length] = new Option('Select category',' ');
   }

   for(var i=0, limit=CTDataList.length; i<limit; i+=3)  
if (chosen == CTDataList[i]) {
  selbox.options[selbox.options.length] = new
Option(CTDataList[i+2],CTDataList[i+1]);
}

}

Open in new window

0
 
lulu50Author Commented:
here's full code of my list
<select name="SelSTPost" size="1" style="width: 180px;"
		onchange="setOptions(this.options[this.selectedIndex].value);"/>
	
		<option value="" >Select type of posting</option>
	
		
		
		<option value="2" selected="selected">Community</option>
		
		
		
		<option value="4" >For Sale</option>
		
		
		
		<option value="6" >Jobs</option>
		
		
		
		<option value="5" >Real Estate</option>
		
		
		
		<option value="7" >Services</option>
		
		
	</select> 
	<select name="SelCatg" size="1" style="width: 180px;"/>
			<option value="" selected="selected">Select category</option>	
	</select>

____________________________________________



   <script language="Javascript">  
function setOptions(chosen) {
var selbox = document.FRMAcc.SelCatg;
var getmySubCat = '3,2,<h1>Churches Bulletin <br>Chat Room</h1>,6,5,Accounting/Finance,2,1,Activities,6,85,Admin,7,164,Advertising,7,165,Animal Care,2,158,Announcements,4,233,Antiques,5,208,Apartment Rentals,4,234,Appliances,6,86,Architect,6,87,Art,2,27,Artists,4,235,Arts/Crafts,4,236,Auto Parts,7,166,Automotive,7,169,Baby Sitting,4,237,Barter,7,167,Beauty & Salon,4,238,Beauty/Health Care,4,239,Bikes,6,88,Biotech,4,240,Boats,4,241,Books,5,209,Building Lot,4,242,Business,6,89,Business,7,168,Car Dealers,4,243,Cars/Trucks,7,170,Catering,4,244,CDS/DVD/VHS,4,245,Cell Phones,2,28,Childcare,2,39,Classes,7,171,Cleaning,4,246,Clothes/Acc,5,211,Co-op Unit,4,247,Collectibles,7,172,Colledge Activities,2,159,College Age,4,248,Computer,5,210,Condominium Unit,7,173,Construction,7,174,Cook,6,90,Craft,7,175,Creative,6,91,Customer service,6,92,Design,5,212,Duplex,6,93,Editing,6,94,Education,7,176,Education,2,269,Elderly,7,177,Elderly Activities,7,178,Elderly Care,7,179,Electrician,4,249,Electronics,6,95,Engineering,7,180,Erotic,2,32,Events,5,213,Farm,4,250,Farm/Garden,7,181,Farm/Garden,7,182,Fast Food Chains,6,96,Film,7,183,Financial,6,97,Fitness,6,98,Food,4,251,Free,7,184,Free fast food delivery,2,155,Free Stuff,4,252,Furniture,4,253,Garage Sale,2,29,General,4,254,General,2,157,General Entertainment,6,99,General labor,6,100,Government,2,30,Groups,6,101,Health,7,185,Health & Wellness,7,186,Home,5,214,Home Rentals,6,102,Hospital,4,255,Household,7,187,Household,5,215,Housing swap,6,103,Human resources,7,188,Insurance,6,104,Internet engineers,2,156,Items Wanted,4,256,Jewelry,2,268,Kids,7,189,Kids Activities,7,190,Labor,7,191,Lawn & Garden,7,192,Legal,6,105,Legal,7,193,Lessons,2,35,Local news,2,33,Lost & Found,6,109,Management,6,106,Manufacturing,6,107,Marketing,4,257,Materials,6,108,Media,2,160,Men,5,216,Mobile/Manufactured Home,4,258,Motorcycles,7,194,Moving & Storage,5,217,Multi-Family Home,4,259,Music Instr,2,34,Musicians,6,110,Network,5,218,New Construction,6,111,Nonprofit sector,7,195,Office,6,112,Office,5,219,Offie/Commercial,5,220,Other Real Estate,7,196,Paint,6,114,Paralegal,5,221,Parking/Storage,7,197,Pet,2,31,Pets,4,260,Photo/Video,7,198,Plummer,2,36,Politics,2,153,Preschoolers,5,222,Raw Land,7,199,Real Estate,6,115,Real Estate,7,200,Rental,6,116,Retail,5,223,Room Wanted,5,224,Roommates,5,225,Rooms/Shared,5,226,Row House,4,261,RVS,6,117,Sales,6,118,Salon,6,119,Science,6,120,Security,5,227,Single Family Home,6,121,Skilled trade,7,201,Skill`d trade,6,122,Software,4,262,Sporting,7,202,Sports,5,228,Sublets/Temporary,6,123,Technical support,2,161,The Gathering Place,4,263,Tickets,5,229,Time Share,4,264,Tools,5,230,Townhouse/Townhome,4,265,Toys/Games,7,203,Training & Education,6,124,Transport,7,204,Travel,6,125,Tv,5,231,Vacation Rentals,5,232,Vacation swap,6,126,Video,4,266,Video Gaming,2,38,Volunteers,4,267,Wanted,6,127,Web design,7,205,Web Design & Tech,7,206,Wedding & Photography,2,154,Weekly Information,6,128,Wholesale,2,152,Women,7,207,Writer,6,129,Writing';
var CTDataList = getmySubCat.split(",");
 
   selbox.options.length = 0;
   if (chosen == " " || chosen != "Select All") {  
   selbox.options[selbox.options.length] = new Option('Select category',' ');
   }
 
   for(var i=0, limit=CTDataList.length; i<limit; i+=3)  
if (chosen == CTDataList[i]) {
  selbox.options[selbox.options.length] = new
Option(CTDataList[i+2],CTDataList[i+1]);
}
 
}

Open in new window

0
 
lulu50Author Commented:
I've requested that this question be deleted for the following reason:

I am not getting any help here <br />cookie is not the solution to my question
0
 
Gurvinder Pal SinghCommented:
check this simplest of example of how to save and preserve user selection
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
	<script>
		function setCookie(c_name,value,exdays)
		{
			var exdate=new Date();
			exdate.setDate(exdate.getDate() + exdays);
			var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
			document.cookie=c_name + "=" + c_value;
		}

		function getCookie(c_name)
		{
			var i,x,y,ARRcookies=document.cookie.split(";");
			for (i=0;i<ARRcookies.length;i++)
			{
				x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
				y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
				x=x.replace(/^\s+|\s+$/g,"");
				if (x==c_name)
				{
					return unescape(y);
				}
			}
		}

		window.onload = function(){
			var cityName = getCookie("cityname");
			if ( cityName != null && cityName.length > 0 )
			{
				document.getElementById( "city" ).value = cityName;
			}
		};

		function saveCityName( value )
		{
			alert(value);
			setCookie( "cityname", value , 365)
		}
	</script>

</HEAD>

<BODY >
	<select id="city" onchange="saveCityName( this.value )">
		<option value="1">One</option>
		<option value="2">Two</option>
		<option value="3">Three</option>
		<option value="4">Four</option>
		<option value="5">Five</option>
		<option value="6">Six</option>
		<option value="7">Seven</option>
	</select>
</BODY>
</HTML>

Open in new window

0
 
lulu50Author Commented:
gurvinder372:

I got it to work!!!!!  by using a cookie thank you
0
 
Gurvinder Pal SinghCommented:
did my answer helped you?
0
 
lulu50Author Commented:
gurvinder372:

I am not able to give you the credit and close this question.

what should I do?

this is what it says:


"This question already has an auto close request. You must cancel the previous request before creating another."
0
 
Gurvinder Pal SinghCommented:
Let me try to object the same again.
0
 
lulu50Author Commented:
Thanks
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 9
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now