Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Radio group and Previously selected

Status
Not open for further replies.

sapras

Programmer
Joined
Jul 7, 2006
Messages
3
Location
GB
Hello Folks

I have a radio group. When I click a radio button I would like to know the previously selected radio button within that group. Say for example I've a radio group with elements 1, 2, 3, 4, 5. By default one of them will be checked. Say 5. Then when I click on 1 how do I know the value of previously selected radio button.

Any help would be highly appreciated.

TIA
 
You will have to keep track of this by assigning an onclick handler to each radio button to store a reference to the newly checked one in a variable.

This variable will need to be set on page load to the default radio button.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks Dan

But I've loads of radio groups on the form and all of them are generated dynamically. The number of radio groups vary based on some parameters in the form. So how do I store the default value for each radio group in variables ?

TA
 
On page load, loop through all radio groups, and then find the checked item (if there is one) for each of those. How you store them is up to you - personally, I'd use a hash map / associative array with the key being the radio group name.

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks Dan !

I thought there would be an easy way to process on the fly for the previously selected radio. Never mind I shall walk in your path....Thanks again for the replies.

sai
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top