Thread: form in asp
View Single Post
  #1 (permalink)  
Old April 13th, 2006, 12:35 PM
seran128 seran128 is offline
Registered User
 
Join Date: Apr 2006
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default form in asp

OK i have two bit of code that work great on their own but I need to merge them the first set is an asp code and follows

<%
Option Explicit

' Let's populate a dropdown with the User Names from
' UserInfo table where contactID 1 should be selected
' in the dropdown

Dim SelectedContactID
SelectedContactID = 2

' We will make a call to Sub Routine PopulateDropDown
' which will select all users from UserInfo table and
' populate a dropdown. This sub routine will also check
' for selected user and marked as SELECTED

Call PopulateDropDown( SelectedContactID )

' *********************************
' Populate Drop Down Sub Routine
' *********************************
Sub PopulateDropDown(byVal SelectedContactID)
 Dim objConn
 Dim objRS
 Dim strSQL
 Dim contactID
 Dim contactName


 Const adOpenForwardOnly = 0
 Const adLockReadOnly = 1

 Set objConn = Server.CreateObject("ADODB.Connection")
 Set objRS = Server.CreateObject("ADODB.Recordset")

 objconn.Provider="SQLOLEDB"
 objConn.Open ="Server=;uid=data_access;pwd=data_access;database =CLIENTS"


 strSQL = "SELECT contactID, contactName FROM contacts"



 objRS.Open strSQL, objConn, adOpenForwardOnly, adLockReadOnly


 Response.Write "<SELECT Name=""contactID"">"
 Response.Write "<OPTION Value=""""></OPTION>"

 ' Loop through the recordset and populate the dropdown
 Do Until objRS.EOF = True
  contactID = objRS("contactID").Value
  contactName = objRS("contactName").Value


  If contactID = SelectedContactID Then
   Response.Write "<OPTION Value=""" & contactID & """ SELECTED>"
   Response.Write contactName
   Response.Write "</OPTION>"
  Else
   Response.Write "<OPTION Value=""" & contactID & """>"
   Response.Write contactName
   Response.Write "</OPTION>"
  End If

 objRS.Movenext
 Loop

 Response.Write "</SELECT>"

 objRS.Close
 Set objRS = Nothing
 Set objConn = Nothing
End Sub

%>

The second code id html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script src="selectcustomer.js"></script>
</head>

<body>

***************************************
<form>
Select a Customer:
<select name="customers" onchange="showCustomer(this.value)">
<option value="31">Alfreds Futterkiste
<option value="1">North/South
<option value="2">Wolski Zajazd
</select>
</form>
***************************************
<p>
<div id="txtHint"><b>Customer info will be listed here.</b></div>
</p>

</body>
</html>


The form tag I would like to replace with the results from the asp code above.