Jump to content

I want to have default search for today, tomorrow or seleceted from to dates


Recommended Posts

You need to have JS on your form. Let's say you have:

Virtual 1 as radio button with these values:

 

1- Today

2- Tomorrow

3- Enter dates

 

Virtual 3 (pass from), virtual 4 (passes to). Add HTML block around these two, in the HTML Block above add:

<table id="mydates" style="display:none;"><td>

and HTML Block below add:

</td></table>

The following code will go to the footer:

<script>

function assign(){
if (document.getElementById('cbParamVirtual10').checked){
document.getElementById('mydates').style.display="none";
document.getElementById('cbParamVirtual3').value = '[@cbTimestamp*]';
document.getElementById('cbParamVirtual4').value = '[@cbTimestamp*]';
} 
else if (document.getElementById('cbParamVirtual11').checked){
document.getElementById('mydates').style.display="none";
f_date();
} else if (document.getElementById('cbParamVirtual12').checked){

document.getElementById('mydates').style.display="block";
document.getElementById('cbParamVirtual3').value = '';
document.getElementById('cbParamVirtual4').value = '';
} 
}

function f_date(){
var today = new Date('[@cbTimestamp*]');
var dd = today.getDate()+1;
var mm = today.getMonth()+1;
 var yyyy = today.getFullYear();

document.getElementById('cbParamVirtual3').value =mm+'/'+dd+'/'+yyyy;
document.getElementById('cbParamVirtual4').value = mm+'/'+dd+'/'+yyyy;
}

document.getElementsByName('cbParamVirtual1')[0].onchange = assign;
document.getElementsByName('cbParamVirtual1')[1].onchange = assign;
document.getElementsByName('cbParamVirtual1')[2].onchange = assign;
</script>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...