943,579 Members | Top Members by Rank

Ad:
  • ColdFusion Discussion Thread
  • Unsolved
  • Views: 2932
  • ColdFusion RSS
Aug 29th, 2009
0

Radio button problem and cfloop

Expand Post »
How can I use cfloop or query my database so I can select home game and away game for multiple selections. I need to select 1 selection for home and away game but have to be able to select 1 of each. here is my output

http://67.219.102.67/wcfootball/index2.cfm

ColdFusion Syntax (Toggle Plain Text)
  1. <script language="JavaScript" type="text/JavaScript">
  2. <!--
  3. function uncheckRadio() {
  4.  var choice = document.form1.RadioGroup1;
  5.  for (i = 0; i < choice.length; i++) {
  6.   if ( choice[i].checked = true )
  7.   choice[i].checked = false;
  8.  }
  9. }
  10. //-->
  11.  
  12.  
  13. <script language="JavaScript">
  14. function checkRegex(object_value, regex) {
  15. return regex.test(object_value);
  16. }
  17.  
  18. function validateform (f) {
  19.  
  20. if (f.Team1.checked == false && f.Team2.checked == false ) {
  21. alert("Please select at least one type of service you are interested in.");
  22. return false;
  23. } else if (f.Team1.checked == true && f.Team2.checked == true ) {
  24. alert("You Must Select only Economy Buster or Lawn Treatment Please un-check one.");
  25. return false;
  26. } else if (f.Team1.value == "") {
  27. alert("Please enter your first name.");
  28. return false;
  29. } else if (f.Team2.value == "") {
  30. alert("Please enter your last name.");
  31. return false;
  32. }
  33. return true;
  34. }
  35.  
  36. function doValidateForm() {
  37. if (validateform(document.frmTeam)) document.frmTeam.submit();
  38. }
  39.  
  40.  
  41. </script>
  42.  
  43. <cfquery name="Get_members" datasource="#application.dsn#">
  44. SELECT * FROM members
  45. </cfquery>
  46.  
  47.  
  48. <table cellspacing="0" cellpadding="0" border="0" width="523">
  49. <cfoutput>
  50. <table cellspacing="0" cellpadding="0" border="0">
  51. <tr>Name<br></td>
  52. <td class="infoBoxShaded">#get_members.first_name# #get_members.last_name#</td>
  53. </tr>
  54. <tr>
  55. <td class="infoBoxShaded">#get_members.address# #get_members.city# #get_members.zip#</td>
  56. <td class="infoBoxShaded"><img src="images/spacer.gif" width="20" height="1" alt="" border="0"></td>
  57. <td class="infoBoxShaded"></td>
  58. <td class="infoBoxShaded" colspan="3"></td>
  59. </tr>
  60. <tr>
  61. <td class="infoBoxShaded">SCORE: #get_members.score#</td>
  62. <td class="infoBoxShaded"><br><br>#session.sessionID#</td>
  63. <td class="infoBoxShaded" colspan="5"></td>
  64. </tr>
  65.  
  66. </table>
  67. </cfoutput>
  68. </table>
  69. <p>&nbsp;</p>
  70.  
  71. <p><strong>Week 1</strong></p>
  72.  
  73.  
  74.  
  75.  
  76. <tr>
  77.  
  78. </tr>
  79.  
  80.  
  81.  
  82. <cfform action="getEstimate_step2.cfm" method="post" name="frmWon">
  83. <input type="Hidden" name="action" value="continue">
  84. <table border="0" cellpadding="1" cellspacing="0" bordercolor="#000000" width="45%">
  85. <tr>
  86. <td><div class="content_black">Game</div></td>
  87. <td><div class="content_black">Week</div></td>
  88. <td><div class="content_black">Home Team</div></td>
  89. <td><div class="content_black">Away</div></td>
  90.  
  91. <cfquery name="Picks" datasource="#application.dsn#">
  92. SELECT distinct Games.game, games.week, games.home_team, games.away_team FROM Games
  93. where games.week = '1'
  94.  
  95.  
  96. </cfquery>
  97.  
  98. </tr>
  99. <cfloop query="Picks">
  100. <cfoutput>
  101. <tr>
  102. <td><div class="content_black">Game #Game#&nbsp;</td>
  103. <td><div class="content_black">Week #Week#&nbsp;</td>
  104. <td><div class="content_black"><cfinput type="radio" name="mainloop" value="1" required="yes" message="Please select the right option">#Home_team#&nbsp;</td>
  105. <td><div class="content_black"><cfinput type="radio" name="mainloop" value="0" required="yes" message="Please select the right option">#Away_team#&nbsp;</td>
  106.  
  107. </tr>
  108. </cfoutput>
  109. </cfloop>
  110. <INPUT type="submit" name="mysubmit" value="Submit">
  111. </cfform>
  112. </table>
Similar Threads
Reputation Points: 12
Solved Threads: 36
Posting Pro in Training
freshfitz is offline Offline
436 posts
since Sep 2008
Sep 11th, 2009
0

Re: Radio button problem and cfloop

Right now you only have 1 radio group with only 1 possible value. Split them up by renaming from mainloop to mainloopH and mainloopA like below:
coldfusion Syntax (Toggle Plain Text)
  1.  
  2. <td><div class="content_black"><cfinput type="radio" name="mainloopH" value="1" required="yes" message="Please select the right option">#Home_team#&nbsp;</td>
  3.  
  4. <td><div class="content_black"><cfinput type="radio" name="mainloopA" value="0" required="yes" message="Please select the right option">#Away_team#&nbsp;</td>
Reputation Points: 232
Solved Threads: 137
Practically a Master Poster
buddylee17 is offline Offline
665 posts
since Nov 2007
Sep 12th, 2009
0

Re: Radio button problem and cfloop

No didn't work http://67.219.102.67/wcfootball/index2.cfm I need them to be able to select 1 team from game 1 1 team from game 2 1 team from game 3 and so on.
Reputation Points: 12
Solved Threads: 36
Posting Pro in Training
freshfitz is offline Offline
436 posts
since Sep 2008
Sep 14th, 2009
0

Re: Radio button problem and cfloop

Then you'll need one unique name for each group of radio buttons (each game):
coldfusion Syntax (Toggle Plain Text)
  1. <cfset i = 1>
  2. <cfloop query="Picks">
  3. <cfoutput>
  4. <tr>
  5. <td><div class="content_black">Game #Game#&nbsp;</td>
  6. <td><div class="content_black">Week #Week#&nbsp;</td>
  7. <td><div class="content_black"><cfinput type="radio" name="mainloopGame#i#" value="1" required="yes" message="Please select the right option">#Home_team#&nbsp;</td>
  8. <td><div class="content_black"><cfinput type="radio" name="mainloopGame#i#" value="0" required="yes" message="Please select the right option">#Away_team#&nbsp;</td>
  9. </tr>
  10. <cfset i = i + 1>
  11. </cfoutput>
  12. </cfloop>
You should also consider cleaning up your html. You have several div tags that aren't closed.
Last edited by buddylee17; Sep 14th, 2009 at 6:52 pm.
Reputation Points: 232
Solved Threads: 137
Practically a Master Poster
buddylee17 is offline Offline
665 posts
since Nov 2007
Sep 14th, 2009
0

Re: Radio button problem and cfloop

OH the first option did work sorry

ColdFusion Syntax (Toggle Plain Text)
  1. <cfquery name="Games" datasource="#application.dsn#">
  2. SELECT * FROM Games
  3. </cfquery>
  4.  
  5. </tr>
  6.  
  7. <tr>
  8. <td><div class="content_black">Game 1&nbsp;</td>
  9. <td><div class="content_black">Week 1&nbsp;</td>
  10.  
  11. <td><div class="content_black"> <input name="RadioGroup" type="radio" value="1" ondblclick="uncheckRadio();">Tenessee Titans&nbsp;</td>
  12. <td><div class="content_black"> <input name="RadioGroup" type="radio" value="0" ondblclick="uncheckRadio();">Pittsburgh Steelers&nbsp;</td>
  13.  
  14. </tr>
  15. <tr>
  16. <td><div class="content_black">Game 2&nbsp;</td>
  17. <td><div class="content_black">Week 1&nbsp;</td>
  18.  
  19. <td><div class="content_black"><input type="radio" name="RadioGroup1" value="1" required="yes" message="Please select the right option">Miami Dolphins&nbsp;;</td>
  20. <td><div class="content_black"><input type="radio" name="RadioGroup1" value="0" required="yes" message="Please select the right option">Atlanta Falcons&nbsp;</td>
  21.  
  22. </tr><tr>
  23. <td><div class="content_black">Game 3&nbsp;</td>
  24. <td><div class="content_black">Week 1&nbsp;</td>
  25.  
  26. <td><div class="content_black"><input type="radio" name="RadioGroup2" value="1" required="yes" message="Please select the right option">Kansas City Chiefs&nbsp;</td>
  27. <td><div class="content_black"><input type="radio" name="RadioGroup2" value="0" required="yes" message="Please select the right option">Baltimore Ravens&nbsp;</td>
  28.  
  29. </tr><tr>
  30. <td><div class="content_black">Game 4&nbsp;</td>
  31. <td><div class="content_black">Week 1&nbsp;</td>
  32.  
  33. <td><div class="content_black"><input type="radio" name="RadioGroup3" value="1" required="yes" message="Please select the right option">Philadelphia Eagles&nbsp;</td>
  34. <td><div class="content_black"><input type="radio" name="RadioGroup3" value="0" required="yes" message="Please select the right option">Carolina Panthers&nbsp;</td>
  35.  
  36. </tr><tr>
  37. <td><div class="content_black">Game 5&nbsp;</td>
  38. <td><div class="content_black">Week 1&nbsp;</td>
  39.  
  40. <td><div class="content_black"><input type="radio" name="RadioGroup4" value="1" required="yes" message="Please select the right option">Denver Broncos&nbsp;</td>
  41. <td><div class="content_black"><input type="radio" name="RadioGroup4" value="0" required="yes" message="Please select the right option">Cincinnati Bengals&nbsp;</td>
  42.  
  43. </tr><tr>
  44. <td><div class="content_black">Game 6&nbsp;</td>
  45. <td><div class="content_black">Week 1&nbsp;</td>
  46.  
  47. <td><div class="content_black"><input type="radio" name="RadioGroup5" value="1" required="yes" message="Please select the right option">Minnesota Vikings&nbsp;</td>
  48. <td><div class="content_black"><input type="radio" name="RadioGroup5" value="0" required="yes" message="Please select the right option">Cleveland Browns&nbsp;</td>
  49.  
  50. </tr>
  51. <center><br><input type="submit" />
  52. </form>
  53.  
  54.  
  55.  
  56. <tr>
  57.  
  58. </tr>
  59.  
  60. </table>
  61.  
  62. </cfif>
Last edited by freshfitz; Sep 14th, 2009 at 8:34 pm.
Reputation Points: 12
Solved Threads: 36
Posting Pro in Training
freshfitz is offline Offline
436 posts
since Sep 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ColdFusion Forum Timeline: dateDiff problem
Next Thread in ColdFusion Forum Timeline: Lock User Accounts





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC