ToddAtWSU Posted May 20, 2007 Share Posted May 20, 2007 I have a grid of radio buttons that I use to vote for a Top Ten. I have x number of rows (1 row for a team) and 10 columns. I have it set up so each radio button in a row is in a group so the rest of the row is disabled upon clicking a radio button and then when a button is clicked inside a column the rest of the column is disabled. This way no team can get voted more than once and no spot can have more than one team voted for. I have a Reset button next to each row so the user can reset their vote for that team. I also want to add a Reset All button that resets all the rows. But I get IE to hang whenever I click the Reset All button. The Reset button works fine. Here is the code for a Reset button. This stuff is in Javascript and par_num == # rows and rad_num == # columns in my grid of radio buttons. // variable to set the number of participants $totalTeams var par_num = '<?php global $totalTeams; echo $totalTeams; ?>'; // variable to set the number of radio buttons per row var rad_num = 10; function reset_radio(row) { // loop through the radio buttons on the row to see which // radio button is selected for( i = 1 ; i <= rad_num ; i++ ) { // if the radio button is selected, // uncheck it and enable the other radio buttons if( document.getElementById( 'par_' + row + '_' + i ).checked ) { // unchecking the button document.getElementById( 'par_' + row + '_' + i ).checked = false; // turning the other radion buttons on change_disable_status( i, false ); return; } } } Here is the code for the Reset All button and this function is located directly below the reset_row( ) function. function reset_all( ) { for( i = 1 ; i < par_num ; i++ ) { reset_radio( i ); } } Here is the code to create my Reset button in PHP echo "<td align=\"center\"><input type=\"button\" value=\"Reset\" onclick=\"reset_radio('" . ( $i + 1 ) . "'); return false;\"/></td>"; And my code to create my Reset All button. <input type="button" value="Reset All" onclick="reset_all( );"/> Thanks for all your help in helping me to try and get my Reset All button to work. Link to comment https://forums.phpfreaks.com/topic/52169-reset-all-radio-button-capability/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.