Jump to content

Recommended Posts

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.