lulu50
asked on
Filter state
Hi,
I have a select box that has a list of states and a textbox to filter by state.
the state filter box suppose to filter but I don't how it's done.
I need help!!
Thank you
I have a select box that has a list of states and a textbox to filter by state.
the state filter box suppose to filter but I don't how it's done.
I need help!!
Thank you
<input id="TxtState" name="TxtState" style="width: 176px" type="text" onKeyUp="this.form.DispStateBox.onchange()"/>
<select name="DispStateBox" style="width: 180px;height:200px;" size="8"
onChange="setCityOptions(this,'TxtCity','GetCity','GetChurch');"
onFocus="this.form.TxtCity.value='';this.form.TxtChurch.value='';" >
<cfoutput>
<cfloop query="DispState">
<option value="#StateID#">#StateName#</option>
</cfloop>
</cfoutput>
</select>
function setCityOptions(theSel,fldNameFilter,fldNameTarget,fldNameTargetChild){
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]);
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Zvonko
THANK YOU THANK YOU AND THANK YOU THIS IS BEAUTIFUL
GREAT!!!!!!!!!!!!!!!!!!!!! !
I LOVE IT !!!!!! BEAUTIFUL !!!!!
THANK YOU
THANK YOU THANK YOU AND THANK YOU THIS IS BEAUTIFUL
GREAT!!!!!!!!!!!!!!!!!!!!!
I LOVE IT !!!!!! BEAUTIFUL !!!!!
THANK YOU
ASKER
A++++++++++++++
EXCELLENT +++++++++++++++
EXCELLENT +++++++++++++++
You are welcome <|:-)
Small note, add the onChange handler to the onFocus handler for State select:
<select name="DispStateBox" style="width: 180px;height:200px;" size="8"
onChange="setCityOptions(this,'TxtCity','GetCity','GetChurch');"
onFocus="this.form.TxtCity.value='';this.form.TxtChurch.value='';this.onchange();" >
</select>
You can do it like you did it before AJAX: you put all States into one List and let the JavaScript recreate the State options at every input of filter key characters. You know what I mean?
You put into State filter input field something like this:
Open in new window
You can even use one of the old scripts that you used before.