Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    May 2003
    Location
    Stockholm, Sweden
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Dynamicly generated forms?

    I wanna enter a number in a input field so that when it's
    submited it will generate a form with that number of rows,
    is this possible?

    I have this code:

    admin.asp

    Code:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Admin Page</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    </head>
    <body>
    <center>
    <form method="post" action="signup.asp">
    <table border="1" style="border-collapse: collapse" bordercolor="#000000">
      <tr>
        <td width="50" align="center"><b>Add</b></td>
    	<td width="100" align="center"><input type="text" size="10" name="amount"></td>
    	<td width="50"><input type="submit" value="Generate Sign Up Form"></td>
      </tr>
    </table>
    </form>
    </center>
    </body>
    </html>
    signup.asp

    Code:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Sign Up Form</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    </head>
    <body>
    <center>
    <FORM METHOD="POST" ACTION="add.asp">
    <table border="1" style="border-collapse: collapse" bordercolor="#000000">
      <tr>
        <td>ID</td>
    	<td>First Name</td>
    	<td>Last Name</td>
    	<td>Team</td>
    	<td>Hcp</td>
      </tr>
      <tr>
        <td><INPUT TYPE="TEXT" SIZE="30" NAME="ID"></td>
    	<td><INPUT TYPE="TEXT" SIZE="30" NAME="Fname"></td>
    	<td><INPUT TYPE="TEXT" SIZE="30" NAME="Lname"></td>
    	<td><INPUT TYPE="TEXT" SIZE="30" NAME="Team"></td>
    	<td><INPUT TYPE="TEXT" SIZE="30" NAME="Hcp"></td>
      </tr>
      <tr align="left">
        <td colspan="5">
        <INPUT TYPE="submit" VALUE="Add Post(s)"> 
    	</td>
      </tr>
    </FORM>
    </center>
    </body>
    </html>
    /Speedy

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Yeah it is possible....Just need to post the page to another page or itself and run a loop that builds the form.
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    Regular Coder
    Join Date
    May 2003
    Location
    Stockholm, Sweden
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok,

    so how does the loop look like then?

    how do I tell the loop how many loops it shall do?

    /Speedy

  • #4
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    get the value from the query string or the form element

    then do a for loop with the value found above

    Request.Write "your form element1"
    Request.Write "your form element2"
    Request.Write "your form element3"

    next


    That is the basic idea.......

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #5
    Regular Coder
    Join Date
    Oct 2003
    Location
    London, UK
    Posts
    411
    Thanks
    0
    Thanked 1 Time in 1 Post
    You could also do this without a client-server roundtrip by dynamically building a form in JS, but cross-browser compatibility would still be a pain, so building the form in ASP probably is the quickest & easiest solution for you.
    Marcus Tucker / www / blog
    Web Analyst Programmer / Voted SPF "ASP Guru"


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •