maxhugen
Posts: 272
|
| Posted: 12/26/2008, 9:50 PM |
|
I'm using radio buttons to allow users to select different date ranges in a Search form, see http://www.gardenloco.com/cal/search.php
However, once you perform the Search, the radio buttons reset to the default ("All").
How should I go about ensuring that the Date Range is still set to the user's last setting?
MTIA
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com |
 |
 |
damian
Posts: 838
|
| Posted: 12/27/2008, 2:14 AM |
|
<input id="DateRange_1" onclick="SetDateRange(this)" type="radio" checked value="1" name="DateRange">
_________________
if you found this post useful take the time to help someone else.... :)
|
 |
 |
ckroon
Posts: 869
|
| Posted: 12/28/2008, 5:54 PM |
|
Thats a great website!
Can you tell me how you got the date range to hide/show off the radio button?
_________________
Walter Kempees...you are dearly missed. |
 |
 |
maxhugen
Posts: 272
|
| Posted: 12/29/2008, 3:47 PM |
|
Quote ckroon:Thats a great website!
Thank you. It's a 'personal project' (ie, unpaid !!!), and I've a long way to go yet.
Quote ckroon:Can you tell me how you got the date range to hide/show off the radio button?
The date range is wrapped in a <div> (id='ShowCustomDate'), and Javascript is used to set the display; see the js function 'ToggleDisplay' in the page source:
function ToggleDisplay() {
if ($("DateRange_4").checked) {
$("ShowCustomDate").style.display = "";
} else {
$("ShowCustomDate").style.display = "none";
}
}
Cheers
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com |
 |
 |
datadoit
|
| Posted: 12/31/2008, 8:16 AM |
|
> function ToggleDisplay() {
> if ($("DateRange_4").checked) {
> $("ShowCustomDate").style.display = "";
> } else {
> $("ShowCustomDate").style.display = "none";
> }
> }
>
Max, interesting usage of '$()' to reference elements on your page,
instead of something like:
document.forms["FormName"].DateRange_4.checked
or
document.getElementById("ShowCustomDate").style.display = ""
Are you using a js framework? CCS 4+?
|
|
|
 |
maxhugen
Posts: 272
|
| Posted: 12/31/2008, 4:54 PM |
|
Oops, didn't realise I'd posted a 'shortcut' there... it's the prototype.js script, which is included with things like the AJAX scripts in CCS4... I've gotten into the habit of adding it myself as the $() is really cool.
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com |
 |
 |
damian
Posts: 838
|
| Posted: 01/01/2009, 3:08 AM |
|
Quote maxhugen:
How should I go about ensuring that the Date Range is still set to the user's last setting?
have you tried setting a session variable on the OnChange event?
check for the session variable on Before Show...?
_________________
if you found this post useful take the time to help someone else.... :)
|
 |
 |
maxhugen
Posts: 272
|
| Posted: 01/02/2009, 4:29 PM |
|
Finally resolved. I had an additional issue caused by using an AJAX Update panel. There doesn't seem to be any method for Javascript to determine when the Ajax update call has completed, so I couldn't use javascript to 'refresh' the display.
While JS is still used to toggle the Date Range settings at the client end, I had to:
1. Add a hidden field which stores the DateRange radio button value
2. Add a Label to the <div> which hides/shows the custom date fields:
<div id="ShowCustomDate" style="display: {DisplayCustomDate}">
The DisplayCustomDate Label is set to "none" unless the DateRange = 4 (ie, custom)
3. Add a Label to each radio button, which is set to "Checked" for the appropriate control.
Happy New Year!
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com |
 |
 |