| | |
Radio button problem and cfloop
Please support our ColdFusion advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Sep 2008
Posts: 337
Reputation:
Solved Threads: 27
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
http://67.219.102.67/wcfootball/index2.cfm
ColdFusion Syntax (Toggle Plain Text)
<script language="JavaScript" type="text/JavaScript"> <!-- function uncheckRadio() { var choice = document.form1.RadioGroup1; for (i = 0; i < choice.length; i++) { if ( choice[i].checked = true ) choice[i].checked = false; } } //--> <script language="JavaScript"> function checkRegex(object_value, regex) { return regex.test(object_value); } function validateform (f) { if (f.Team1.checked == false && f.Team2.checked == false ) { alert("Please select at least one type of service you are interested in."); return false; } else if (f.Team1.checked == true && f.Team2.checked == true ) { alert("You Must Select only Economy Buster or Lawn Treatment Please un-check one."); return false; } else if (f.Team1.value == "") { alert("Please enter your first name."); return false; } else if (f.Team2.value == "") { alert("Please enter your last name."); return false; } return true; } function doValidateForm() { if (validateform(document.frmTeam)) document.frmTeam.submit(); } </script> <cfquery name="Get_members" datasource="#application.dsn#"> SELECT * FROM members </cfquery> <table cellspacing="0" cellpadding="0" border="0" width="523"> <cfoutput> <table cellspacing="0" cellpadding="0" border="0"> <tr>Name<br></td> <td class="infoBoxShaded">#get_members.first_name# #get_members.last_name#</td> </tr> <tr> <td class="infoBoxShaded">#get_members.address# #get_members.city# #get_members.zip#</td> <td class="infoBoxShaded"><img src="images/spacer.gif" width="20" height="1" alt="" border="0"></td> <td class="infoBoxShaded"></td> <td class="infoBoxShaded" colspan="3"></td> </tr> <tr> <td class="infoBoxShaded">SCORE: #get_members.score#</td> <td class="infoBoxShaded"><br><br>#session.sessionID#</td> <td class="infoBoxShaded" colspan="5"></td> </tr> </table> </cfoutput> </table> <p> </p> <p><strong>Week 1</strong></p> <tr> </tr> <cfform action="getEstimate_step2.cfm" method="post" name="frmWon"> <input type="Hidden" name="action" value="continue"> <table border="0" cellpadding="1" cellspacing="0" bordercolor="#000000" width="45%"> <tr> <td><div class="content_black">Game</div></td> <td><div class="content_black">Week</div></td> <td><div class="content_black">Home Team</div></td> <td><div class="content_black">Away</div></td> <cfquery name="Picks" datasource="#application.dsn#"> SELECT distinct Games.game, games.week, games.home_team, games.away_team FROM Games where games.week = '1' </cfquery> </tr> <cfloop query="Picks"> <cfoutput> <tr> <td><div class="content_black">Game #Game# </td> <td><div class="content_black">Week #Week# </td> <td><div class="content_black"><cfinput type="radio" name="mainloop" value="1" required="yes" message="Please select the right option">#Home_team# </td> <td><div class="content_black"><cfinput type="radio" name="mainloop" value="0" required="yes" message="Please select the right option">#Away_team# </td> </tr> </cfoutput> </cfloop> <INPUT type="submit" name="mysubmit" value="Submit"> </cfform> </table>
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)
<td><div class="content_black"><cfinput type="radio" name="mainloopH" value="1" required="yes" message="Please select the right option">#Home_team# </td> <td><div class="content_black"><cfinput type="radio" name="mainloopA" value="0" required="yes" message="Please select the right option">#Away_team# </td>
Lost time is never found again.
- Benjamin Franklin
- Benjamin Franklin
•
•
Join Date: Sep 2008
Posts: 337
Reputation:
Solved Threads: 27
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.
Then you'll need one unique name for each group of radio buttons (each game):
You should also consider cleaning up your html. You have several div tags that aren't closed.
coldfusion Syntax (Toggle Plain Text)
<cfset i = 1> <cfloop query="Picks"> <cfoutput> <tr> <td><div class="content_black">Game #Game# </td> <td><div class="content_black">Week #Week# </td> <td><div class="content_black"><cfinput type="radio" name="mainloopGame#i#" value="1" required="yes" message="Please select the right option">#Home_team# </td> <td><div class="content_black"><cfinput type="radio" name="mainloopGame#i#" value="0" required="yes" message="Please select the right option">#Away_team# </td> </tr> <cfset i = i + 1> </cfoutput> </cfloop>
Last edited by buddylee17; Sep 14th, 2009 at 6:52 pm.
Lost time is never found again.
- Benjamin Franklin
- Benjamin Franklin
•
•
Join Date: Sep 2008
Posts: 337
Reputation:
Solved Threads: 27
OH the first option did work sorry
ColdFusion Syntax (Toggle Plain Text)
<cfquery name="Games" datasource="#application.dsn#"> SELECT * FROM Games </cfquery> </tr> <tr> <td><div class="content_black">Game 1 </td> <td><div class="content_black">Week 1 </td> <td><div class="content_black"> <input name="RadioGroup" type="radio" value="1" ondblclick="uncheckRadio();">Tenessee Titans </td> <td><div class="content_black"> <input name="RadioGroup" type="radio" value="0" ondblclick="uncheckRadio();">Pittsburgh Steelers </td> </tr> <tr> <td><div class="content_black">Game 2 </td> <td><div class="content_black">Week 1 </td> <td><div class="content_black"><input type="radio" name="RadioGroup1" value="1" required="yes" message="Please select the right option">Miami Dolphins ;</td> <td><div class="content_black"><input type="radio" name="RadioGroup1" value="0" required="yes" message="Please select the right option">Atlanta Falcons </td> </tr><tr> <td><div class="content_black">Game 3 </td> <td><div class="content_black">Week 1 </td> <td><div class="content_black"><input type="radio" name="RadioGroup2" value="1" required="yes" message="Please select the right option">Kansas City Chiefs </td> <td><div class="content_black"><input type="radio" name="RadioGroup2" value="0" required="yes" message="Please select the right option">Baltimore Ravens </td> </tr><tr> <td><div class="content_black">Game 4 </td> <td><div class="content_black">Week 1 </td> <td><div class="content_black"><input type="radio" name="RadioGroup3" value="1" required="yes" message="Please select the right option">Philadelphia Eagles </td> <td><div class="content_black"><input type="radio" name="RadioGroup3" value="0" required="yes" message="Please select the right option">Carolina Panthers </td> </tr><tr> <td><div class="content_black">Game 5 </td> <td><div class="content_black">Week 1 </td> <td><div class="content_black"><input type="radio" name="RadioGroup4" value="1" required="yes" message="Please select the right option">Denver Broncos </td> <td><div class="content_black"><input type="radio" name="RadioGroup4" value="0" required="yes" message="Please select the right option">Cincinnati Bengals </td> </tr><tr> <td><div class="content_black">Game 6 </td> <td><div class="content_black">Week 1 </td> <td><div class="content_black"><input type="radio" name="RadioGroup5" value="1" required="yes" message="Please select the right option">Minnesota Vikings </td> <td><div class="content_black"><input type="radio" name="RadioGroup5" value="0" required="yes" message="Please select the right option">Cleveland Browns </td> </tr> <center><br><input type="submit" /> </form> <tr> </tr> </table> </cfif>
Last edited by freshfitz; Sep 14th, 2009 at 8:34 pm.
![]() |
Similar Threads
- Problem in Radio button (JSP)
- display image next to radio button list problem (PHP)
- Problem with Radio Button error "[object HTMLInputElement]" (PHP)
- Radio Button - AJAX - Problem with Passing Value (JavaScript / DHTML / AJAX)
- Problem with Radio Button / AJAX (JavaScript / DHTML / AJAX)
- problem in checking focus of radio button (JavaScript / DHTML / AJAX)
- Am not able to get a radio button selection to display in output (PHP)
- Security Settings -> Java permission -> Custom (radio button) -> Java Custom Settings (Web Browsers)
- Problem passing value from radio button to second page. (PHP)
Other Threads in the ColdFusion Forum
- Previous Thread: dateDiff problem
- Next Thread: Lock User Accounts
| Thread Tools | Search this Thread |





