#1
  1. No Profile Picture
    Contributing User
    ASP Explorer (0 - 99 posts)

    Join Date
    Aug 2009
    Posts
    37
    Rep Power
    10

    Dynamically name a form and fields


    I am trying to name an ASP form and the fields dynamically and can't seem to get it right. It is suppose to create 2 forms. One named casetext1 with an input field named casetext1 and the other form named casetext2 with an input field name casetext2. In this example there are only 2 records in the table. Here's what I have right now:
    Code:
    sSQL = "SELECT * FROM tcases WHERE caseid =" & (intvalue) & " " & _
                 "ORDER BY casedate, casetime" %>
    Set oRecordSet = adoCon.Execute(sSQL)
    If Not oRecordSet.EOF Then
       arrResultSet1 = oRecordSet.GetRows()
       Set oRecordSet = Nothing %>
       iRowNumber1 = ubound(arrResultSet1,2)
       For iCounter1= 0 to iRowNumber1
          'arrResultSet1(3,iCounter1) = caseid ----I just put this here so everyone would know what value it contain. It's either 1 or 2
          <form name="casetext<% Response.Write (arrResultSet1(3,iCounter1)) %>" action="getcasenotes.asp" method="post">
             <input class="caseinput" name"casetext<% Response.Write (arrResultSet1(3,iCounter1)) %>" value="<% Response.Write (arrResultSet1(3,iCounter1)) %>" type="text">
          </form>
          '---This is where I been trying to display the results ---'
         Session ("strfieldname") = Request.Form("casetext" & arrResultSet1(3,iCounter1)")
         response.write ("Field Name: " & Session ("strfieldname")) 
        <% Next %>
    <% End If %>
    After loop ends there should be 2 forms. Session("strfieldname") should equal 2 because the Function looped through both records.
    The Response.Write ("Field Name: " & Session ("strfieldname")) should display "Field Name: casetext2", but it displays only "Field Name:" so obviously I'm not doing something right.

    The reason for trying to name the forms and fields this way is because each client can have any number of cases linked to them and I'm using a link on the page to let the user select which case notes to display based on the caseid
    If anyone has time to point out my errors or make any suggestions I'd really appreciate
    Thanks, Mike
  2. #2
  3. Guru
    ASP Adventurer (500 - 999 posts)

    Join Date
    May 2003
    Location
    USA
    Posts
    923
    Rep Power
    79
    It seems like on the second page which is the page being posted to that there might be a problem with this:
    Session ("strfieldname") = Request.Form("casetext" & arrResultSet1(3,iCounter1)")

    And the problem would be that it doesn't know what arrResultSet1(3,iCounter1) is.

    So perhaps on the first page put in a dynamically named hidden field and then on the second page you can Request.Form() read the contents of that field.
    J. Paul Schmidt
    www.Bullschmidt.com - Freelance Web and Database Developer
    www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips

Similar Threads

  1. Dynamically Adding Fields
    By bobbabuoy in forum Microsoft SQL Server
    Replies: 3
    Last Post: December 4th, 2007, 06:30 AM
  2. Dynamically create text fields in form and fill data
    By navkeshchawla in forum Microsoft Access Help
    Replies: 2
    Last Post: April 6th, 2007, 02:23 AM
  3. Dynamically adding blank form fields?
    By twopecker in forum ASP Development
    Replies: 5
    Last Post: January 10th, 2006, 07:13 AM
  4. Listing large number of fields dynamically
    By twistedkarma in forum ASP Development
    Replies: 2
    Last Post: April 5th, 2005, 05:36 AM
  5. Creating Database Fields Dynamically
    By dcampos in forum ASP Development
    Replies: 1
    Last Post: August 16th, 2004, 04:41 PM

IMN logo majestic logo threadwatch logo seochat tools logo