Gazing into my crystal ball I observed "Dave" <ov******@cogeco.ca>
writing in news:kt*******************@read2.cgocable.net:
Hi folks,
I'm fairly new to the ASP/SQL arena and need a hand wrapping my mind
around something. First allow me to paint you a picture:
I'm developing an ASP page (not .net) for inventory management.
At the moment I have 2 tables.
1) ProductTable has the following columns: ID, Part, Description, Price
and Manufacturer (INT value)
2) ManufacturerTable: ID (key to manufacturer above), ManuName
I have a form in which a user enters information on a new product and
on this form I have a drop down list which is populated via the
ManuName table which displays all available manufacturers from the
manufacturertable.manufacturer column.
What I want is that when a user hits submit, it saves the info to the
producttable and takes the corresponding integer from the
ManuName that the user selects and places it in the
ProductTable.Manufacturer value along with the rest of the info. I'm
unsure of how to capture the corresponding integer value based on the
Manufacturer Name (which is a text value) and send it to the ASP file
doing the actual insert. Can anyone lend a hand?
You have the id of the manufacturer as you pull it out for the drop down
don't you?
<form method="post" action="post.asp">
<label for="manufacturer">
<select name="manufacturer" id="manufacturer">
<%
While Not rs.EOF
id = trim(rs("manufacturer"))
manuname = trim(rs("manuname"))%>
<option value="<%=id%>"><%=manuname%></option>
<% rs.MoveNext
wend
rs.Close
set rs = nothing
%>
</select>
</label>
<label for="part">
<input type="text" id="part" name="part" value="<%=part%>" /></label>
<label for="description">
<input type="text" id="description" name="description" value="<%
=description%>" /></label>
<label for="price">
<input type="text" id="price" name="price" value="<%=price%>" />
</label>
<input type="submit" value="Submit" />
</form>
Now in Post.asp
<% manufacturer = request.form("manufacturer")
part = request.form("part")
description = request.form("description")
price = request.form("price")
insert = "INSERT INTO producttable "
insert = insert & " (Part, Description, Price, Manufacturer)"
insert = insert & " VALUES ('" & part & "', '" & description & "', '" &
price & "', " & manufacturer & ")"
Have a look at
http://www.intraproducts.com/beta/requiredform.asp for some
ways to deal with required information, and other code snippets.
--
Adrienne Boswell
http://www.cavalcade-of-coding.info
Please respond to the group so others can share