lev has asked for the wisdom of the Perl Monks concerning the following question:
In one frame of a frameset, I have a radio group that allows for a selection at two levels with an embedded set of buttons. When a user selects (which survey type-which year) via the radio group, a perl–cgi script is activated. The resulting data (less than half a line) is printed out on this same frame. My interest is to maintain the radio buttons as selected for the user to see, but when activating this frame by clicking a second level radio button, the buttons collapse(lower level disappears) to their pre-selected state. I thought of using a textfield to which the data could be passed passively with the required script moved to another frame,which seems clumsy or of adding another thin frame to where the perl-cgi script could be moved and activated across frames,allowing the resulting data to be printed out directly, keeping the radio group intact as selected.
A third and maybe more ‘monkish’ approach could be to maintain the state of the selected radio group, but I’m not sure how to start or if it is at all appropriate here. I saw there is a store and restore trick with $q->save(FILEHANDLE)and $q = new CGI(FILEHANDLE), but can I save/return just the radio button selection? How (where) do I alter the script?
Thanks for your help#!/usr/local/bin/perl -w use DBI; use DBD::mysql; use CGI qw(:standard); $query = new CGI; use CGI::Carp qw(fatalsToBrowser); my $JSCRIPT = <<EOF; function doit(which){ //SETTING RADIO BUTTONS var num = 3; //NUMBER OF SUB-MENU'S TO SHOW/HIDE //; for(var count=1;count<=num;count++)\{ var div = document.getElementById('subDiv'+count); if(count==which){ div.style.display = 'inline';} else{div.style.display = 'none';} } } EOF ; print $query->startform(-name=>'depts'); print b("Choose the type of data:"),p; ….. print "<label><input type='radio' name='RadioGroup1' value=1 onClick=' +doit(3)'>\n"; print "graphics</label>\n"; print "<span id='subDiv3' style='display:none'>\n"; #float:left with s +tyle, puts subgrp line below print "<label><input type='radio' name='RadioGroup2' value='graphics7' + onClick='pass(this.value)'>\n"; print "2007</label>\n"; print "<label><input type='radio' name='RadioGroup2' value='graphics8' + onClick='pass(this.value)'>\n"; print "'08</label>\n"; print "<label><input type='radio' name='RadioGroup2' value='graphics9' + onClick='pass(this.value)'>\n"; print "'09</label></span></div>\n"; ……. sqlQuery my $mosyr_ref = surveymos(\@dblist); …….. print h4(u('Survey Months with Violations:'),"  $mosyr[0]  $mo +syr[1]"); #RESULTING DATA
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do I maintain a radio button selection
by techcode (Hermit) on Feb 25, 2009 at 01:32 UTC |