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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

drop down menu/combo box 2

Status
Not open for further replies.

tziviak2

MIS
Jul 20, 2004
53
US
I want the user to be able to choose from a list and according to the value-I want to insert a value in a table.
ex. user can choose from apple/banana/pear. if the user chooses apple-then enter 1 in the field, banana-2,pear-3.
I need the user to choose from many different lists-before they press on a button-to record the value. how would I go about it?
thank you
 
<select> box is what u are looking for...

Known is handfull, Unknown is worldfull
 
I've never done that before-can you please guide me a bit?
thank you
 
Something like this:

page1.asp: form with a drop down and submit button

<form method="POST" action="page2.asp">
<select size="1" name="mydropdown">
<option value="1">Apple</option>
<option value="2">Banana</option>
<option value="3">Pear</option>
</select>
<input type="submit" value="Submit" name="B1">
</form>

page2.asp capture the selected value from drop down

dropdownval=Request.Form("mydropdown")

-L
 
I got the first part-but I don't understand how to get the info into the table (what should be in page2?
 
yes-I have to insert 1,2,or 3 into a table-depending on the user's respone
thank u
 
Ok then do something like this:

'create a connection object

SET OBJCOMM = SERVER.CREATEOBJECT("ADODB.Connection")

'strConnect is your connection string to the database

OBJCOMM.Open strConnect

'then write the query

sql = "INSERT INTO yourtablename(choice1) VALUES ('"&request.form("mydropdown")&"')"

'then execute your query

OBJCOMM.EXECUTE (strSql)


let me know if you need any more help

-L
 
thanks -what if I have 4 combo boxes-and each one has to go into another field?
 
Then do this:

sql = "INSERT INTO yourtablename(choice1,choice2,choice3,choice4) VALUES ('"&request.form("mydropdown1")&"','"&request.form("mydropdown2")&"','"&request.form("mydropdown3")&"','"&request.form("mydropdown4")&"')"


-L
 
what do I enter by action-the first line of the form?
 
the action would be the asp page to which you are posting the values selected by the users from the drop down boxes...

if you still have any problems...post your complete code here...

-L
 
here's the code-is the sql statment in the right place because the page wouldn't load

thanks


<form method="POST" action="results.asp">
<select size="1" name="MOM">
<option value="0">METHODS OF MEASUREMENT:</option><BR>
<option value="1">Teacher Made Materials</option><BR>
<option value="2">Standarized Tests</option><BR>
<option value="3">Class Activities</option><BR>
<option value="4">Portfolio(s)</option><BR>
<option value="5">Teacher/Provider Observations</option><BR>
<option value="6">Performance Assessment Task</option><BR>
<option value="7">Check Lists</option><BR>
<option value="8">Verbal Explanation</option><BR>
<option value="9">Other</option><BR>


</select>

<select size="1" name="ROP">
<option value="0">REPORT OF PROGRESS:</option><BR>
<option value="1">Not applicable during this grading period</option><BR>
<option value="2">No progress made</option><BR>
<option value="3">Little progress made</option><BR>
<option value="4">Progress made; goal not yet met</option><BR>
<option value="5">Goal Met</option><BR>


</select>
<select size="1" name="PTG">
<option value="0">PROGRESS TOWARDS GOAL:</option><BR>
<option value="A">Anticipate Meeting Goal</option><BR>
<option value="B">Do not anticipate meeting goal</option><BR>
<option value="C">Goal Met</option><BR>

</select>&nbsp;&nbsp;
<select size="1" name="RFNMG">
<option value="0">REASONS FOR NOT MEETING GOALS:</option><BR>
<option value="1">More time needed</option><BR>
<option value="2">Excessive absence or lateness</option><BR>
<option value="3">Assignments not completed</option><BR>
<option value="4">Other</option><BR>

</select></p>

<% sql = "INSERT INTO tblGoalsReportCard ( measuMeth, progReport, progTowardsGoal, ReasNotMeetinGoal)"
sql= sql & "values (" & request.form("MOM") & "," & request.form("ROP") & ","request.form("PTG") & ","request.form("RFNMG") & ")"
sql=sql & "where rcRecNum=" & rcRecNum
conn.execute(sql)
%>


<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
 
page 1:

Code:
<form method="POST" action="results.asp">
  <select size="1" name="MOM">
  <option value="0">METHODS OF MEASUREMENT:</option><BR>
 <option value="1">Teacher Made Materials</option><BR>
 <option value="2">Standarized Tests</option><BR>
<option value="3">Class Activities</option><BR>
<option value="4">Portfolio(s)</option><BR>
<option value="5">Teacher/Provider Observations</option><BR>
<option value="6">Performance Assessment Task</option><BR>
<option value="7">Check Lists</option><BR>
<option value="8">Verbal Explanation</option><BR>
<option value="9">Other</option><BR>

  
  </select>
  
  <select size="1" name="ROP">
  <option value="0">REPORT OF PROGRESS:</option><BR>
 <option value="1">Not applicable during this grading period</option><BR>
 <option value="2">No progress made</option><BR>
<option value="3">Little progress made</option><BR>
<option value="4">Progress made; goal not yet met</option><BR>
<option value="5">Goal Met</option><BR>

  
  </select>
  <select size="1" name="PTG">
  <option value="0">PROGRESS TOWARDS GOAL:</option><BR>
 <option value="A">Anticipate Meeting Goal</option><BR>
 <option value="B">Do not anticipate meeting goal</option><BR>
<option value="C">Goal Met</option><BR>

  </select>&nbsp;&nbsp;
  <select size="1" name="RFNMG">
  <option value="0">REASONS FOR NOT MEETING GOALS:</option><BR>
 <option value="1">More time needed</option><BR>
 <option value="2">Excessive absence or lateness</option><BR>
<option value="3">Assignments not completed</option><BR>
<option value="4">Other</option><BR>

  </select></p>
<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>

page 2: results.asp

Code:
<%     
'you have to create a connection object conn before using it...
'something like this:

SET conn = SERVER.CREATEOBJECT("ADODB.Connection")

'then open your connection string to connect to the database

conn.Open strConnect

sql = "INSERT INTO tblGoalsReportCard ( measuMeth, progReport, progTowardsGoal, ReasNotMeetinGoal)" 
    sql= sql &     "values (" & request.form("MOM") & "," & request.form("ROP") & ","request.form("PTG") & ","request.form("RFNMG") & ")"
    sql=sql &  "where rcRecNum=" & rcRecNum
    conn.execute(sql)
    %>

to know more about connection strings go to this following link


let me know if you need any more help

-L
 
I highly recommend that you check out the ADO tutorial at It won't take long to work through, and it will give you the basics you need for working with ASP and a database. In addition their ASP tutorial is good and quick.

And all free.
 
Also if you want to show a confirmation box to your users after they select and click submit then put this piece of code in page 2: results.asp...

<script type="text/javascript">
alert("Your Selection has been recorded")
window.location= "page1.asp"
</script>


your whole code for page2 (results.asp) should look something like this:

Code:
<body>
Dim conn,sql

SET conn = SERVER.CREATEOBJECT("ADODB.Connection")

conn.ConnectionString= "Provider=SQLOLEDB;Data Source = yourdatasourcename; Database=yourdatabasename;User ID=blahblah;Password=blah"

conn.Open

sql = "INSERT INTO tblGoalsReportCard ( measuMeth, progReport, progTowardsGoal, ReasNotMeetinGoal)" 
    sql= sql &     "values (" & request.form("MOM") & "," & request.form("ROP") & ","request.form("PTG") & ","request.form("RFNMG") & ")"
    sql=sql &  "where rcRecNum=" & rcRecNum
    conn.execute(sql)

<script type="text/javascript">
alert("Your Selection has been recorded")
window.location= "page1.asp"
</script>

</body>
-L
 
I did set a connection-top of the page-the page that it's going to is the same page-just reloading it the current page.
so where would i insert the code?
thank you for all your help
 
I've been working on it-and did look at w3school but I'm getting this error when loading page:
Microsoft JET Database Engine error '80040e10'

No value given for one or more required parameters.

/reportcard.asp, line 348

line 348 is conn.execute(sql)

and the sql is :

sql="UPDATE tblGoalsReportCard SET MeasuMeth = " & request.form("MOM") & ", ProgReport = " & request.form("ROP") & ", ProgTowardsGoal = " & request.form("PTG") & ", ReasNotMeetingGoal = " & request.form("RFNMG")
sql=sql & " WHERE (tblGoalsReportCard.rcRecNum= " & rs("rcRecNum") & ")"

I put this code right after the form-on the same page since right after the user clicks on the submit button I want this page to reload (and according to the qry which I'm loading the page with-some info won't show up anymore-if the user responded to it)
code: <form method="POST" action="results.asp?ReportType=G">

basically the user has a list of items that they have to evaluate-and as soon as they evaluate one-when the page gets reloaded-the item evaluated will pop off and only the items that weren't evaluated will remain-that is why I redirect it to the same page-is that ok?

thank you

let me know if you want me to show you more code.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top