Forums

ASP

This topic is locked

Dynamic Drop down to database

Posted 22 Aug 2006 19:04:53
1
has voted
22 Aug 2006 19:04:53 Shona Smith posted:
Hi

another one !

I have this code which is great yet the second drop down is not submitted to a database.

So really would appreceate any ideas.

<%
' FP_ASP ASP Automatically generated by a Frontpage Component. Do not Edit.
On Error Resume Next

strErrorUrl = ""

If Request.ServerVariables("REQUEST_METHOD" = "POST" Then
If Request.Form("VTI-GROUP" = "0" Then
Err.Clear

Set fp_conn = Server.CreateObject("ADODB.Connection"
FP_DumpError strErrorUrl, "Cannot create connection"

Set fp_rs = Server.CreateObject("ADODB.Recordset"
FP_DumpError strErrorUrl, "Cannot create record set"

fp_conn.Open Application("DropDown3_ConnectionString"
FP_DumpError strErrorUrl, "Cannot open database"

fp_rs.Open "Results", fp_conn, 1, 3, 2 ' adOpenKeySet, adLockOptimistic, adCmdTable
FP_DumpError strErrorUrl, "Cannot open record set"

fp_rs.AddNew
FP_DumpError strErrorUrl, "Cannot add new record set to the database"
Dim arFormFields0(2)
Dim arFormDBFields0(2)
Dim arFormValues0(2)

arFormFields0(0) = "example"
arFormDBFields0(0) = "example"
arFormValues0(0) = Request("example"
arFormFields0(1) = "stage2"
arFormDBFields0(1) = "stage2"
arFormValues0(1) = Request("stage2"


FP_SaveFormFields fp_rs, arFormFields0, arFormDBFields0

FP_SaveFieldToDB fp_rs, Now, "Timestamp"

fp_rs.Update
FP_DumpError strErrorUrl, "Cannot update the database"

fp_rs.Close
fp_conn.Close

FP_FormConfirmation "text/html; charset=windows-1252",_
"Form Confirmation",_
"Thank you for submitting the following information:",_
"ddbasic2.asp",_
"Return to the form."

End If
End If

%>
<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 2</title>
</head>
<body>
<form name="doublecombo" action="--WEBBOT-SELF--" method="POST">
<!--webbot bot="SaveDatabase" SuggestedExt="asp" S-DataConnection="DropDown3" S-RecordSource="Results" U-Database-URL="../../../fpdb/DropDown3.mdb" S-Builtin-Fields="HTTP_USER_AGENT REMOTE_HOST Timestamp REMOTE_USER" S-Builtin-DBFields="Browser_type Remote_computer_name Timestamp User_name" S-Form-Fields="stage2 example" S-Form-DBFields="stage2 example" -->
<p><select name="example" size="1" onChange="redirect(this.options.selectedIndex)">
<option>Departments</option>
<option>CI</option>
<option>PER</option>
</select>
<select name="stage2" language="JavaScript" name="Doublecombo" size="1">
<option>Cost Centre Codes</option>
<option value="557420">557420</option>
<option value="557123">557123</option>
</select>
<input type="submit" name="test" value="Go!"
onClick="go()">
</p>

<script>
<!--



var groups=document.doublecombo.example.options.length

var group=new Array(groups)
for (i=0; i<groups; i++)
group[i]=new Array()

group[0][0]=new Option("",""
group[0][1]=new Option("557420",""
group[0][2]=new Option("",""

group[1][0]=new Option("557420",""


group[2][0]=new Option("557123",""


var temp=document.doublecombo.stage2

function redirect(x){
for (m=temp.options.length-1;m>0;m--)
temp.options[m]=null
for (i=0;i<group[x].length;i++){
temp.options[i]=new Option(group[x][i].text,group[x][i].value)
}
temp.options[0].selected=true
}

function go(){
location=temp.options[temp.selectedIndex].value
}
//-->
</script>

</form>

</body>


<body>

</body>

</html>
Thanks Shona

Replies

Replied 28 Aug 2006 21:56:23
28 Aug 2006 21:56:23 Mike Mitchell replied:
I use Dreamweaver to create complex forms all the time (multiple database-driven dropdown menus). In my experience, the problem is usually with the INSERT command. Go back through it and make sure the second menu is listed in there (and that it doesn't have the word <ignore> next to it).

Reply to this topic