supanoob Posted October 9, 2007 Share Posted October 9, 2007 Ok so i have a 5x5 grid filled with 25 Option Buttons, now i want to make a loop that circles through them to see which one is selected and then compares that to a number in the database to see if something should be done. Is this possible? if so how? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted October 9, 2007 Share Posted October 9, 2007 Post your code so we can see whats going on. Do all the options have the same name attribute? Quote Link to comment Share on other sites More sharing options...
supanoob Posted October 9, 2007 Author Share Posted October 9, 2007 <form method="POST" action="--WEBBOT-SELF--"> <!--webbot bot="SaveResults" U-File="fpweb:///_private/form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" --> <table border="0" width="7%" id="table1" cellspacing="0" cellpadding="0"> <tr> <td>5</td> <td background="http://www.porkyproductions.com/images/map/water.gif"> <input type="radio" value="V1" name="R1" checked></td> <td background="http://www.porkyproductions.com/images/map/water.gif"><input type="radio" value="V2" name="R1"></td> <td background="http://www.porkyproductions.com/images/map/water.gif"><input type="radio" value="V3" name="R1"></td> <td background="http://www.porkyproductions.com/images/map/water.gif"><input type="radio" value="V4" name="R1"></td> <td background="http://www.porkyproductions.com/images/map/water.gif"><input type="radio" value="V5" name="R1"></td> </tr> <tr> <td>4</td> <td background="http://www.porkyproductions.com/images/map/water.gif"><input type="radio" value="V16" name="R1"></td> <td background="http://www.porkyproductions.com/images/map/water.gif"><input type="radio" value="V17" name="R1"></td> <td background="http://www.porkyproductions.com/images/map/water.gif"><input type="radio" value="V18" name="R1"></td> <td background="http://www.porkyproductions.com/images/map/water.gif"><input type="radio" value="V19" name="R1"></td> <td background="http://www.porkyproductions.com/images/map/water.gif"><input type="radio" value="V6" name="R1"></td> </tr> <tr> <td background="http://www.porkyproductions.com/images/map/water.gif">3</td> <td background="http://www.porkyproductions.com/images/map/water.gif"><input type="radio" value="V15" name="R1"></td> <td background="http://www.porkyproductions.com/images/map/water.gif"><input type="radio" value="V22" name="R1"></td> <td background="http://www.porkyproductions.com/images/map/water.gif"><input type="radio" value="V21" name="R1"></td> <td background="http://www.porkyproductions.com/images/map/water.gif"><input type="radio" value="V20" name="R1"></td> <td background="http://www.porkyproductions.com/images/map/water.gif"><input type="radio" value="V7" name="R1"></td> </tr> <tr> <td>2</td> <td background="http://www.porkyproductions.com/images/map/water.gif"><input type="radio" value="V14" name="R1"></td> <td background="http://www.porkyproductions.com/images/map/water.gif"><input type="radio" value="V23" name="R1"></td> <td background="http://www.porkyproductions.com/images/map/water.gif"><input type="radio" value="V24" name="R1"></td> <td background="http://www.porkyproductions.com/images/map/water.gif"><input type="radio" value="V25" name="R1"></td> <td background="http://www.porkyproductions.com/images/map/water.gif"><input type="radio" value="V8" name="R1"></td> </tr> <tr> <td>1</td> <td background="http://www.porkyproductions.com/images/map/water.gif"><input type="radio" value="V13" name="R1"></td> <td background="http://www.porkyproductions.com/images/map/water.gif"><input type="radio" value="V12" name="R1"></td> <td background="http://www.porkyproductions.com/images/map/water.gif"><input type="radio" value="V11" name="R1"></td> <td background="http://www.porkyproductions.com/images/map/water.gif"><input type="radio" value="V10" name="R1"></td> <td background="http://www.porkyproductions.com/images/map/water.gif"><input type="radio" value="V9" name="R1"></td> </tr> <tr> <td align="center"> </td> <td align="center">1</td> <td align="center">2</td> <td align="center">3</td> <td align="center">4</td> <td align="center">5</td> </tr> </table> <p><input type="submit" value="Submit" name="B1"></p> </form> thats pretty much it. Basically it will be a fishing thing but the fish will move and you have to guess where they have moved too. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted October 9, 2007 Share Posted October 9, 2007 You don't need a loop for this. All of your radio buttons have the same name, which means only one can be selected. The value of the selected button will be returned in $_POST['R1']. Ken Quote Link to comment Share on other sites More sharing options...
supanoob Posted October 9, 2007 Author Share Posted October 9, 2007 so how would i know which part of the grid it is? i was planning on changing the R1 to the Coords on the 5x5 grid. So i would need a loop right? the coords would be like 11 | 21 | 31 | 41 | 51 12 | 22 | 32 | 42 | 51 etc etc then i would need to do a loop to see which one matchs the number in the db. Quote Link to comment Share on other sites More sharing options...
supanoob Posted October 9, 2007 Author Share Posted October 9, 2007 anyone? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted October 10, 2007 Share Posted October 10, 2007 You have all the grids values labeled from v1-v24 which will be stored in the $_POST['R1'] variable. So you will know which part of the grid is selected because they all have different values. Now you would just do a query based on that to see if it matches the one in the database or whatever. If that isn't what your trying to do, you need to explain a little more. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.