This topic is locked

Automatically search "Between" dates on Advanced Search Page

8/10/2011 2:05:45 PM
ASPRunnerPro Tips and tricks
admin

Lets says you need to set advanced search page to default values. When somebody goes to advanced search page for this field to automatically have selected "between" and the two search fields to be populated; the first one with a date 2 weeks prior to today's date and the second one to have today's date in it.
To do so add the following code to Javscript OnLoad event of the Search page. Change field name from 'Date Listed' to the actual field name.

var name='Date Listed';

var name1=name.replace(' ','_');
$("#srchOpt_1_"+name1).val('Between');

$("#srchOpt_1_"+name1).trigger('change');

var ctrl = Runner.getControl(pageid, name);

var d1 = new Date();

d1.setDate(d1.getDate() - 14);

ctrl.setValue(d1);
var ctrl2 = Runner.controls.ControlManager.getAt(false, 1, name,1);

var d2 = new Date();

ctrl2.setValue(d2);
J
jvolz 6/8/2012



Lets says you need to set advanced search page to default values. When somebody goes to advanced search page for this field to automatically have selected "between" and the two search fields to be populated; the first one with a date 2 weeks prior to today's date and the second one to have today's date in it.
To do so add the following code to Javscript OnLoad event of the Search page. Change field name from 'Date Listed' to the actual field name.

var name='Date Listed';

var name1=name.replace(' ','_');
$("#srchOpt_1_"+name1).val('Between');

$("#srchOpt_1_"+name1).trigger('change');

var ctrl = Runner.getControl(pageid, name);

var d1 = new Date();

d1.setDate(d1.getDate() - 14);

ctrl.setValue(d1);
var ctrl2 = Runner.controls.ControlManager.getAt(false, 1, name,1);

var d2 = new Date();

ctrl2.setValue(d2);



I just added a new post and I've tried this but it didn't work for me. I copied the code and only changed 'Date Listed' to 'SOLD' which is my table field but no luck. I want to add multiple betweens which I'd like to show on advanced search options page if possible. I actually tried adding the code to both the Menu page JS OnLoad event and the Search Page JS Onload event but neither worked.

admin 6/10/2012

Just in case you use correct field names (case-sensitive). If this doesn't help post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.