This topic is locked

Automatically search "Between" dates on Advanced Search Page

8/10/2011 2:02:53 PM
PHPRunner Tips and Tricks
Sergey Kornilov 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);
D
DouglasB 9/5/2011

This works perfect. Just what I needed..THANK YOU!



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
jdu001 10/29/2015



This works perfect. Just what I needed..THANK YOU!


Thank you Sergey,
This was exact what I was looking for.
Best regards,
Jo van Duin