I am relatively new to asp, and need some help.

I have a form that a drop down box is dynamically populated with TeamNames, and this works.
I then pass this information, via a submit button (action=get) to another page that I want to show the Team Name, then list each member of that team, with an input box associated with that team member to enter miles run. Each team has an 'ID' associated with it. I can get the Team Name to show up, but the members names do not. I know it's how I'm passing the information, but just can't figure out what I'm doing wrong.

Drop down page code:

<%
session("TeamName") = TeamName
session("Member1") = Member1
session("Member2") = Member2
session("Member3") = Member3
session("Member4") = Member4

Cmd = "SELECT ID, Member1, Member2, Member3, Member4 FROM MillionTeams WHERE TeamName = '" & TeamName & "'"

If Request.Querystring("GET") = "yes" Then
rs.open cmd, conn
ID = rs("ID")
TeamName = rs("TeamName")
rs.close

Cmd = "SELECT * FROM MillionTeams WHERE ID = "' & ID & "'"
Rs.Open Cmd, Conn
 ID = Request.Form("ID")
 TeamName = Replace(Request.Form("TeamName"),"'","''")
 Member1 = Request.Form("Member1")
 Member2 = Request.Form("Member2")
 Member3 = Request.Form("Member3")
 Member4 = Request.Form("Member4")
Rs.Close

Then the display page coding is:

<%
TeamName = Request.querystring("TeamName")
cmd = "SELECT * FROM MillionSteps WHERE TeamName = '" & TeamName & "'"

If request.querystring("Get") = "yes" Then
 ID = Request.Form("ID")
 cmd = "SELECT * FROM MillionSteps WHERE TeamName = '" & TeamName & "'"
 rs.open cmd, conn, adOpenStatic, adLockOptimistic
	
 Dim ID, Member1, Member2, Member3, Member4
		
 ID = Request.Form("ID")
 TeamName = Request.Form("TeamName")	
 Member1 = Request.Form("Member1")
 Member2 = Request.Form("Member2")
 Member3 = Request.Form("Member3")
 Member4 = Request.Form("Member4")
 Member1Miles = Request.Form("Member1Miles")
 Member2Miles = Request.Form("Member2Miles")
 Member3Miles = Request.Form("Member3Miles")
 Member4Miles = Request.Form("Member4Miles")

  rs("TeamName") = TeamName
  rs("Member1") = Member1
  rs("Member2") = Member2
  rs("Member3") = Member3
  rs("Member4") = Member4
  rs("Member1Miles") = Member1Miles
  rs("Member2Miles") = Member2Miles
  rs("Member3Miles") = Member3Miles
  rs("Member4Miles") = Member4Miles
						
 rs.update
 rs.close
		
Else
 ID = Request.querystring("ID")
 cmd = "SELECT * FROM MillionSteps WHERE TeamName = '" & TeamName & "'"
%>

I know my coding isn't pulling the information correctly, and some is for the entering of the miles in the database, but I need to be able to associate the information pulled up on the display page with the correct team/team members so I can enter the milage for each correct team. I've messed with this so long, and tried so many different things, that some of the code probably isn't even necessary anymore.

Help!!

Yeah I must say, it definitely isn't needed (most of it).

If you're receiving the team name, then your form is requesting correctly, and there are typos somewhere else, like within the member#. Check to see that you have "Member1" and "Member2"..... spelled correctly, and remember that this is case-sensitive. Another thing you should do, is post both pages, exactly, and I will tell you what you need and don't need, and how to fix it.

It's a lot of coding, but here goes...

The first page

<!-- #include file="inc.asp" -->

<%
session("TeamName") = TeamName
session("Member1") = Member1
session("Member2") = Member2
session("Member3") = Member3
session("Member4") = Member4

 Cmd = "SELECT ID, Member1, Member2, Member3, Member4 FROM MillionTeams WHERE TeamName = '" & TeamName & "'"

 If Request.Querystring("GET") = "yes" Then

 rs.open cmd, conn
 ID = rs("ID")
 TeamName = rs("TeamName")
 rs.close

 Cmd = "SELECT * FROM MillionTeams WHERE ID = "' & ID & "'"
 Rs.Open Cmd, Conn
  ID = Request.Form("ID")
  TeamName = Replace(Request.Form("TeamName"),"'","''")
  Member1 = Request.Form("Member1")
  Member2 = Request.Form("Member2")
  Member3 = Request.Form("Member3")
  Member4 = Request.Form("Member4")
 Rs.Close

Else
%>

<!-- #Include file="../header.asp"-->
<DIV align=center>
<TABLE height=456 cellSpacing=0 cellPadding=0 width=715 border=0>
 <TR>
  <TD vAlign=top width="508" height="456">
   <table border="0" cellpadding="3" cellspacing="0" width="508" height="512">
   <tr>
    <td width="508" valign="top" align="center"><font face="Arial" size="5" color="#800000">Walk a Million Steps</font></td>
   </tr>
   <tr>
    <center>
    <td width="508" valign="top" align="left"><b><font face="Arial" color="#FFFFFF" size="2">&nbsp;&nbsp;&nbsp;</font></b></center>
     <table border="0" cellspacing="0" cellpadding="4" width="525" height="460" style="border-collapse: collapse" bordercolor="#111111">
     <tr>
      <TD vAlign=top align=left><i><b><font face="Arial" color="#800000">Please Choose Your Team</font></b></i>
     <blockquote>

     <form method="GET" action="MillionSteps.asp" target="_self">

      <table border="0" cellpadding="2" cellspacing="0" width="80%" style="border-collapse: collapse" bordercolor="#111111">
      <tr>
       <td width="100%" align="right" colspan="3"><p align="center"><font face="Verdana" size="2">&nbsp;</font></td>
      </tr>
      <tr>
       <td width="31%" align="right"><font face="Verdana" size="2">Team Name</font></td>
       <td width="4%"><font face="Verdana" size="2">&nbsp;</font></td>
       <td width="65%"><font face="Verdana" size="2">
        <select size="1" name="TeamName">
        <option selected value="">Choose Your Team</option>
          <% Set rs = Server.CreateObject("ADODB.RecordSet")
                rs.Open "MillionTeams", conn
                While NOT rs.EOF
                response.write "<option value=""" & rs("TeamName") & """>" & rs("TeamName") & "</option>" & vbcrlf
                rs.MoveNext
                Wend
                rs.Close
                Set rs = Nothing
          %>
        </select>
        </font></td>
      </tr>
      <tr>
        <td width="31%"><font face="Verdana" size="2">&nbsp;</font></td>
        <td width="4%"><font face="Verdana" size="2">&nbsp;</font></td>
        <td width="65%"><font face="Verdana" size="2">&nbsp;</font></td>
      </tr>
      <tr>
        <td width="100%" align="center" colspan="3"><font face="Verdana"><input type="submit" value="Go" name="Go"> <input type="reset" value="Reset" name="B2"></font></td>
      </tr>
      </table>

      </form>
      </blockquote>
     </TD>
    </tr>
    </table>
   </td>
   </center>
  </tr>
  </table>
  </TD>
  <TD vAlign=top width=207><p align="left"><!-- #Include file="../menu.asp"--></TD>
 </TR>
</TABLE>
</DIV>
 <p><!-- #Include file="../footer.asp"--></p>
<% End If %>

And the second page is...

<!-- #include file="inc.asp" -->
<%

TeamName = Request.querystring("TeamName")
ID = Request.Form("ID")

cmd = "SELECT * FROM MillionSteps WHERE TeamName = '" & TeamName & "'"

If request.querystring("Get") = "yes" Then

 ID = Request.Form("ID")
 cmd = "SELECT * FROM MillionSteps WHERE TeamName = '" & TeamName & "'"
 rs.open cmd, conn, adOpenStatic, adLockOptimistic

  Dim ID, Member1, Member2, Member3, Member4
  ID = Request.Form("ID")
  TeamName = Request.Form("TeamName")	
  Member1 = Request.Form("Member1")
  Member2 = Request.Form("Member2")
  Member3 = Request.Form("Member3")
  Member4 = Request.Form("Member4")
  Member1Miles = Request.Form("Member1Miles")
  Member2Miles = Request.Form("Member2Miles")
  Member3Miles = Request.Form("Member3Miles")
  Member4Miles = Request.Form("Member4Miles")

   rs("TeamName") = TeamName
   rs("Member1") = Member1
   rs("Member2") = Member2
   rs("Member3") = Member3
   rs("Member4") = Member4
   rs("Member1Miles") = Member1Miles
   rs("Member2Miles") = Member2Miles
   rs("Member3Miles") = Member3Miles
   rs("Member4Miles") = Member4Miles

   rs.update
   rs.close

Else
   ID = Request.querystring("ID")
   cmd = "SELECT * FROM MillionSteps WHERE TeamName = '" & TeamName & "'"

   rs.open cmd, conn
%>

<!-- #Include file="../header.asp"-->
<DIV align=center>
<TABLE height=456 cellSpacing=0 cellPadding=0 width=715 border=0>
<TR>
 <TD vAlign=top width="508" height="456">
  <table border="0" cellpadding="3" cellspacing="0" width="508" height="512">
  <tr>
   <td width="508" valign="top" align="center"><font face="Verdana" size="5" color="#800000">Walk a Million Steps</font></td>
  </tr>
  <tr>
   <center>
   <td width="508" valign="top" align="left"><b><font face="Verdana" color="#FFFFFF" size="2">&nbsp;&nbsp;&nbsp;</font></b></center>	
    <table border="0" cellspacing="0" cellpadding="4" width="508" height="460">
    <tr>
     <TD vAlign=top>
     <form method="GET" action="MillionSteps.asp">
       <table border="0" cellpadding="2" cellspacing="0" width="99%">
       <tr>
        <td width="100%" align="center" colspan="3">
        <p align="center"><font face="Verdana" size="2"><b>Team Name</b> = <%=TeamName%> <%=ID%></font></p>
        <p align="center"><font face="Verdana" size="2">Enter Mileage Here:</font></p>
        </td>
       </tr>
       <tr>
        <td width="45%" align="right">&nbsp;</td>
        <td width="4%"><font face="Verdana" size="2">&nbsp;</font></td>
        <td width="51%"><font face="Verdana" size="2">&nbsp;</font></td>
       </tr>
       <tr>
        <td width="45%" align="right"><font face="Verdana" size="2">

        <%=Member1%>
       <% Set rs = Server.CreateObject("ADODB.RecordSet")
              rs.Open "MillionTeams", conn
              While NOT rs.EOF
              response.write(Member1)
              rs.MoveNext
              Wend
              rs.Close
              Set rs = Nothing
       %>

        </font></td>
        <td width="4%"><font face="Verdana" size="2">&nbsp;</font></td>
        <td width="51%"><font face="Verdana" size="2"><input type="text" name="Member1Miles" size="10"></font></td>
       </tr>
       <tr>
        <td width="45%" align="right"><font face="Verdana" size="2">
        <% Set rs = Server.CreateObject("ADODB.RecordSet")
              rs.Open "MillionTeams", conn
              While NOT rs.EOF
              response.write(Member2)
              rs.MoveNext
              Wend
              rs.Close
              Set rs = Nothing
        %>
        </font></td>
        <td width="4%"><font face="Verdana" size="2">&nbsp;</font></td>
        <td width="51%"><font face="Verdana" size="2"><input type="text" name="Member2Miles" size="10"></font></td>
       </tr>
       <tr>
        <td width="45%" align="right"><font face="Verdana" size="2">
        <% Set rs = Server.CreateObject("ADODB.RecordSet")
              rs.Open "MillionTeams", conn
              While NOT rs.EOF
              response.write(Member3)
              rs.MoveNext
              Wend
              rs.Close
              Set rs = Nothing
        %>
        </font></td>
        <td width="4%"><font face="Verdana" size="2">&nbsp;</font></td>
        <td width="51%"><font face="Verdana" size="2"><input type="text" name="Member3Miles" size="10"></font></td>
       </tr>
       <tr>
        <td width="45%" align="right"><font face="Verdana" size="2">
        <% Set rs = Server.CreateObject("ADODB.RecordSet")
              rs.Open "MillionTeams", conn
              While NOT rs.EOF
              response.write(Member4)
              rs.MoveNext
              Wend
              rs.Close
              Set rs = Nothing
        %>
        </font></td>
        <td width="4%"><font face="Verdana" size="2">&nbsp;</font></td>
        <td width="51%"><font face="Verdana" size="2"><input type="text" name="Member4Miles" size="10"></font></td>
       </tr>
       <tr>
        <td width="45%"><font face="Verdana" size="2">&nbsp;</font></td>
        <td width="4%"><font face="Verdana" size="2">&nbsp;</font></td>
        <td width="51%"><font face="Verdana" size="2">&nbsp;</font></td>
       </tr>
       <tr>
        <td width="100%" align="center" colspan="3"><font face="Verdana"><input type="submit" value="Submit" name="B1"> <input type="reset" value="Reset" name="B2"></font></td>
       </tr>
       </table>

       </form>

       <p align="center"><b><font face="Verdana">Each Team Member will need a monthly log</font></b></p>
       <p align="center"><b><font face="Verdana" size="2"><a href="FebLog.doc">February Logs</a></font></b></p>
       <p align="center"><b><font face="Verdana" size="2"><a href="MarchLog.doc">March Logs</a></font></b></p>
       <p align="center"><b><font face="Verdana" size="2"><a href="AprilLog.doc">April Logs</a></font></b></p>
       <p align="center"><b><font face="Verdana" size="2"><a href="MayLog.doc">May Logs</a></font></b></p></TD>
      </tr>
      </table>
     </td>
    </tr>
    </table>
   </TD>
   <TD vAlign=top width=207><p align="left"><!-- #Include file="../menu.asp"--></TD>
  </TR>
  </TABLE>
</DIV>
<p><!-- #Include file="../footer.asp"--></p>
</BODY>
</HTML>
<% End If %>

I've checked all the spellings and don't see any misspellings. Your help is greatly appreciated!!

Okay, don't worry, that's not much coding at all. When you start building bigger applications, it's very common to see one page have 1200 lines or more. Most of my pages with coding had a minimum of 700 lines. Anyway, the list of errors is below:

1. ID = Request.Form("ID") --> You have no field on the form for "ID", so no information is being pulled.

2. TeamName = Request.querystring("TeamName") --> Suprising this worked as it should be defaulted as a "POST" form, but anyway..
Request.QueryString grabs the information from the URL after the "?" and relates it back to the page. This only works under the method="get".
Request.Form grabs the information from the submitted form.

3. Request.QueryString("Get") --> Again, there are no fields on your form for "Get", and your form should be submitting via "Post" by default, so this wouldn't work anyway.

Here is the code, edited, for how it should work:
Page2

<!-- #include file="inc.asp" -->
<%
Dim TeamName

TeamName = Request.Form("TeamName")

'Following line doesn't do anything
'ID = Request.Form("ID")

cmd = "SELECT * FROM MillionSteps WHERE TeamName = '" & TeamName & "'"

If Request.ServerVariables("REQUEST_METHOD") = "Post" Then

 ID = Request.Form("ID")
 cmd = "SELECT * FROM MillionSteps WHERE TeamName = '" & TeamName & "'"
 rs.open cmd, conn, adOpenStatic, adLockOptimistic

  Dim ID, Member1, Member2, Member3, Member4
  ID = Request.Form("ID")
  TeamName = Request.Form("TeamName")	
  Member1 = Request.Form("Member1")
  Member2 = Request.Form("Member2")
  Member3 = Request.Form("Member3")
  Member4 = Request.Form("Member4")
  Member1Miles = Request.Form("Member1Miles")
  Member2Miles = Request.Form("Member2Miles")
  Member3Miles = Request.Form("Member3Miles")
  Member4Miles = Request.Form("Member4Miles")

   rs("TeamName") = TeamName
   rs("Member1") = Member1
   rs("Member2") = Member2
   rs("Member3") = Member3
   rs("Member4") = Member4
   rs("Member1Miles") = Member1Miles
   rs("Member2Miles") = Member2Miles
   rs("Member3Miles") = Member3Miles
   rs("Member4Miles") = Member4Miles

   rs.update
   rs.close

Else
   ID = Request.querystring("ID")
   cmd = "SELECT * FROM MillionSteps WHERE TeamName = '" & TeamName & "'"

   rs.open cmd, conn
%>

<!-- #Include file="../header.asp"-->
<DIV align=center>
<TABLE height=456 cellSpacing=0 cellPadding=0 width=715 border=0>
<TR>
 <TD vAlign=top width="508" height="456">
  <table border="0" cellpadding="3" cellspacing="0" width="508" height="512">
  <tr>
   <td width="508" valign="top" align="center"><font face="Verdana" size="5" color="#800000">Walk a Million Steps</font></td>
  </tr>
  <tr>
   <center>
   <td width="508" valign="top" align="left"><b><font face="Verdana" color="#FFFFFF" size="2">&nbsp;&nbsp;&nbsp;</font></b></center>	
    <table border="0" cellspacing="0" cellpadding="4" width="508" height="460">
    <tr>
     <TD vAlign=top>
     <form method="GET" action="MillionSteps.asp">
       <table border="0" cellpadding="2" cellspacing="0" width="99%">
       <tr>
        <td width="100%" align="center" colspan="3">
        <p align="center"><font face="Verdana" size="2"><b>Team Name</b> = <%=TeamName%> <%=ID%></font></p>
        <p align="center"><font face="Verdana" size="2">Enter Mileage Here:</font></p>
        </td>
       </tr>
       <tr>
        <td width="45%" align="right">&nbsp;</td>
        <td width="4%"><font face="Verdana" size="2">&nbsp;</font></td>
        <td width="51%"><font face="Verdana" size="2">&nbsp;</font></td>
       </tr>
       <tr>
        <td width="45%" align="right"><font face="Verdana" size="2">

        <%=Member1%>
       <% Set rs = Server.CreateObject("ADODB.RecordSet")
              rs.Open "MillionTeams", conn
              While NOT rs.EOF
              response.write(Member1)
              rs.MoveNext
              Wend
              rs.Close
              Set rs = Nothing
       %>

        </font></td>
        <td width="4%"><font face="Verdana" size="2">&nbsp;</font></td>
        <td width="51%"><font face="Verdana" size="2"><input type="text" name="Member1Miles" size="10"></font></td>
       </tr>
       <tr>
        <td width="45%" align="right"><font face="Verdana" size="2">
        <% Set rs = Server.CreateObject("ADODB.RecordSet")
              rs.Open "MillionTeams", conn
              While NOT rs.EOF
              response.write(Member2)
              rs.MoveNext
              Wend
              rs.Close
              Set rs = Nothing
        %>
        </font></td>
        <td width="4%"><font face="Verdana" size="2">&nbsp;</font></td>
        <td width="51%"><font face="Verdana" size="2"><input type="text" name="Member2Miles" size="10"></font></td>
       </tr>
       <tr>
        <td width="45%" align="right"><font face="Verdana" size="2">
        <% Set rs = Server.CreateObject("ADODB.RecordSet")
              rs.Open "MillionTeams", conn
              While NOT rs.EOF
              response.write(Member3)
              rs.MoveNext
              Wend
              rs.Close
              Set rs = Nothing
        %>
        </font></td>
        <td width="4%"><font face="Verdana" size="2">&nbsp;</font></td>
        <td width="51%"><font face="Verdana" size="2"><input type="text" name="Member3Miles" size="10"></font></td>
       </tr>
       <tr>
        <td width="45%" align="right"><font face="Verdana" size="2">
        <% Set rs = Server.CreateObject("ADODB.RecordSet")
              rs.Open "MillionTeams", conn
              While NOT rs.EOF
              response.write(Member4)
              rs.MoveNext
              Wend
              rs.Close
              Set rs = Nothing
        %>
        </font></td>
        <td width="4%"><font face="Verdana" size="2">&nbsp;</font></td>
        <td width="51%"><font face="Verdana" size="2"><input type="text" name="Member4Miles" size="10"></font></td>
       </tr>
       <tr>
        <td width="45%"><font face="Verdana" size="2">&nbsp;</font></td>
        <td width="4%"><font face="Verdana" size="2">&nbsp;</font></td>
        <td width="51%"><font face="Verdana" size="2">&nbsp;</font></td>
       </tr>
       <tr>
        <td width="100%" align="center" colspan="3"><font face="Verdana"><input type="submit" value="Submit" name="B1"> <input type="reset" value="Reset" name="B2"></font></td>
       </tr>
       </table>

       </form>

       <p align="center"><b><font face="Verdana">Each Team Member will need a monthly log</font></b></p>
       <p align="center"><b><font face="Verdana" size="2"><a href="FebLog.doc">February Logs</a></font></b></p>
       <p align="center"><b><font face="Verdana" size="2"><a href="MarchLog.doc">March Logs</a></font></b></p>
       <p align="center"><b><font face="Verdana" size="2"><a href="AprilLog.doc">April Logs</a></font></b></p>
       <p align="center"><b><font face="Verdana" size="2"><a href="MayLog.doc">May Logs</a></font></b></p></TD>
      </tr>
      </table>
     </td>
    </tr>
    </table>
   </TD>
   <TD vAlign=top width=207><p align="left"><!-- #Include file="../menu.asp"--></TD>
  </TR>
  </TABLE>
</DIV>
<p><!-- #Include file="../footer.asp"--></p>
</BODY>
</HTML>
<% End If %>

However, to be completely honest, it's a mess. I don't know how you're getting half the variables you are, but if it works, it works.

The ID field is the primary key and generated when the team enters their team name and the four members. Each team has a unique ID number. My thought was to use this to make sure any miles entered went to the correct team (just incase any two teams are named the same thing). It doesn't actually come from the form, it comes from the database.

Well I believe you have a lot of misc stuff there you do not need.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.