CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 [Resolved] Radio Button Setting Lost in Search Form

Print topic Send  topic

Author Message
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
View profile  Send private message
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.... :)
View profile  Send private message
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.
View profile  Send private message
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
View profile  Send private message
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
View profile  Send private message
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.... :)
View profile  Send private message
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
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.