Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form in a form???

Status
Not open for further replies.

Telsa

Programmer
Jun 20, 2000
393
US
Is it possible to make a form in a form on a web page? I created a drop down list using the form so it pulls data from my database for the user to select. But in the end, I want the results of all the fields be captured for the next page. Hence a form within a form.

I'm I going about this wrong? I just can't get the submit button to take me to the page that is designated in the action parameter of the first form tag. However, my dropdown does work for selecting an item to for the main form.
Mary :)

Rule 1: Don't sweat the small stuff.
Rule 2: EVERYTHING is small stuff!! X-)
 
Maybe I am unclear about your question, but a dropdown can be contained inside of a form with several other fields...just think of it as another component like a text box or a radio button. just make sure that the dropdown has a name and when you submit to the next page or database or whatever the Value selected in the drop down will be passed along with it. I fear there is more to it that i am not understanding, if this is the case please post a little more info I am sure we/I can help


Bassguy

 
I'm sorry I wasn't clear. The drop down is dynamically populated from a table in my database. I thought in order to make it do that, I have to create it as a form so it will get the data and create my option data. But this field is part of a larger form.

Is there another way I can get the data from my table on the fly for the drop down without calling it a form? Mary :)

Rule 1: Don't sweat the small stuff.
Rule 2: EVERYTHING is small stuff!! X-)
 
No, you don't have to create it as a form unto itself.... in fact, forms are the only thing that I know of in HTML that you cannot nest --

So, if you want to have the box dynamically created, just do as bassguy suggested and have it be an element of a form. Here's an example. Let's say we have a table -- two fields -- id, and name -- called theTable

<form name=theForm method=post action=somePage.asp>
<%
dim con
set con = server.createobject(&quot;ADODB.Connection&quot;)
dim rs
set rs = server.createobject(&quot;ADODB.Recordset&quot;)
con.open (&quot;DSN=myDSN;UID=uid;PWD=pwd&quot;)
rs.open &quot;SELECT * FROM theTable&quot;, con
%>
<select name=theSelect>
<option value=none>SELECT ONE</option>
<%
while not rs.eof
response.write(&quot;<option value=&quot; & rs(&quot;id&quot;) & &quot;>&quot;)
response.write(rs(&quot;name&quot;) & &quot;</option>&quot;)
rs.movenext
wend
set rs = nothing
set con = nothing
%>
</select>
</form>

And there you have it -- an element of a form populated from the contents of theTable.

If you nest <form> tags inside other <form> tags, your pages will not function properly because it confuses the browser -- doesn't know what to do when the submit button is pressed

hope that helps! :)
Paul Prewett
penny.gif
penny.gif
 
Thanks! I pondered about that last night and am glad you confirmed it! Mary :)

Rule 1: Don't sweat the small stuff.
Rule 2: EVERYTHING is small stuff!! X-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top