Can you put a <div> around a set of radio buttons to get the selected value and then use the document.getElementByID to get that value in Javascript? I am using if/else statements for a search box and I want those values to stay down if they are already selected and the page redraws, so how do I know the <div id='search_pref_ind'> has the right value? THANKS!
var pref_ind=document.getElementById("search_pref_ind").value;
Here is the radio button input:
echo "<div='search_pref_ind'>";
if ($search_pref_ind==''){
echo "<td><input type='radio' class='radio_b' name='search_pref_ind' value ='N' >Not Preferred </td>\n";
echo "<td><input type='radio' name ='search_pref_ind' class='radio_b' value='Y' >Preferred</td>\n";
echo "<td><input type='radio' name='search_pref_ind' class='radio_b' value= 'A' checked >ALL</td>\n";
}else {
if ( $search_pref_ind=='N' ) {
echo "<td><input type='radio' name ='search_pref_ind' class='radio_b' value='N' checked >Not Preferred</td>\n";
echo "<td><input type='radio' name ='search_pref_ind' class='radio_b' value='Y'>Preferred</td>\n";
echo "<td><input type='radio' name ='search_pref_ind' class='radio_b' value='A'>ALL</td>\n";
}elseif($search_pref_ind=='Y'){
echo "<td><input type='radio' name='search_pref_ind' class='radio_b' value ='N' >Not Preferred</td>\n";
echo "<td><input type='radio' name ='search_pref_ind' class='radio_b' value='Y' checked>Preferred</td>\n";
echo "<td><input type='radio' name ='search_pref_ind' class='radio_b' value='A'>ALL</td>\n";
}elseif($search_print_flag=='A'){
echo "<td><input type='radio' name='search_pref_ind' class='radio_b' value ='N'>Not Preferred</td>\n";
echo "<td><input type='radio' name ='search_pref_ind' class='radio_b' value='Y'>Preferred</td>\n";
echo "<td><input type='radio' name ='search_pref_ind' class='radio_b' value='A' checked>ALL</td>\n";
}
}//end else
echo "</div>";