0

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

<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>&nbsp;</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#&nbsp;</td>
	<td><div class="content_black">Week #Week#&nbsp;</td>
	<td><div class="content_black"><cfinput type="radio" name="mainloop" value="1" required="yes" message="Please select the right option">#Home_team#&nbsp;</td>
	<td><div class="content_black"><cfinput type="radio" name="mainloop" value="0" required="yes" message="Please select the right option">#Away_team#&nbsp;</td>
   
</tr>
</cfoutput>
</cfloop>
<INPUT type="submit" name="mysubmit" value="Submit">
</cfform>
</table>
2
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by freshfitz
0

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:

<td><div class="content_black"><cfinput type="radio" name="mainloopH" value="1" required="yes" message="Please select the right option">#Home_team#&nbsp;</td>

<td><div class="content_black"><cfinput type="radio" name="mainloopA" value="0" required="yes" message="Please select the right option">#Away_team#&nbsp;</td>
0

Then you'll need one unique name for each group of radio buttons (each game):

<cfset i = 1>
<cfloop query="Picks">
<cfoutput>
<tr>
	<td><div class="content_black">Game #Game#&nbsp;</td>
	<td><div class="content_black">Week #Week#&nbsp;</td>
	<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>
	<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> 
</tr>
<cfset i = i + 1> 
</cfoutput>
</cfloop>

You should also consider cleaning up your html. You have several div tags that aren't closed.

Edited by buddylee17: n/a

0

OH the first option did work sorry

<cfquery name="Games" datasource="#application.dsn#">
                SELECT * FROM Games
               </cfquery>
	
</tr>

<tr>
    <td><div class="content_black">Game 1&nbsp;</td>
	<td><div class="content_black">Week 1&nbsp;</td>
   
	<td><div class="content_black">  <input name="RadioGroup"  type="radio" value="1" ondblclick="uncheckRadio();">Tenessee Titans&nbsp;</td>
	<td><div class="content_black">  <input name="RadioGroup"  type="radio" value="0" ondblclick="uncheckRadio();">Pittsburgh Steelers&nbsp;</td>
   
</tr>
<tr>
    <td><div class="content_black">Game 2&nbsp;</td>
	<td><div class="content_black">Week 1&nbsp;</td>
   
	<td><div class="content_black"><input type="radio" name="RadioGroup1" value="1" required="yes" message="Please select the right option">Miami Dolphins&nbsp;;</td>
	<td><div class="content_black"><input type="radio" name="RadioGroup1" value="0" required="yes" message="Please select the right option">Atlanta Falcons&nbsp;</td>
   
</tr><tr>
    <td><div class="content_black">Game 3&nbsp;</td>
	<td><div class="content_black">Week 1&nbsp;</td>
   
	<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>
	<td><div class="content_black"><input type="radio" name="RadioGroup2" value="0" required="yes" message="Please select the right option">Baltimore Ravens&nbsp;</td>
   
</tr><tr>
    <td><div class="content_black">Game 4&nbsp;</td>
	<td><div class="content_black">Week 1&nbsp;</td>
   
	<td><div class="content_black"><input type="radio" name="RadioGroup3" value="1" required="yes" message="Please select the right option">Philadelphia Eagles&nbsp;</td>
	<td><div class="content_black"><input type="radio" name="RadioGroup3" value="0" required="yes" message="Please select the right option">Carolina Panthers&nbsp;</td>
   
</tr><tr>
    <td><div class="content_black">Game 5&nbsp;</td>
	<td><div class="content_black">Week 1&nbsp;</td>
   
	<td><div class="content_black"><input type="radio" name="RadioGroup4" value="1" required="yes" message="Please select the right option">Denver Broncos&nbsp;</td>
	<td><div class="content_black"><input type="radio" name="RadioGroup4" value="0" required="yes" message="Please select the right option">Cincinnati Bengals&nbsp;</td>
   
</tr><tr>
    <td><div class="content_black">Game 6&nbsp;</td>
	<td><div class="content_black">Week 1&nbsp;</td>
   
	<td><div class="content_black"><input type="radio" name="RadioGroup5" value="1" required="yes" message="Please select the right option">Minnesota Vikings&nbsp;</td>
	<td><div class="content_black"><input type="radio" name="RadioGroup5" value="0" required="yes" message="Please select the right option">Cleveland Browns&nbsp;</td>
   
</tr>
<center><br><input type="submit" />
</form>

 
  
<tr>
	
</tr>

</table>

</cfif>

Edited by freshfitz: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.