Subject: form in asp
Posted By: seran128 Post Date: 4/13/2006 12:35:24 PM
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.




Reply By: seran128 Reply Date: 4/13/2006 2:50:16 PM
Changed the asp block to something like this

Response.Write "<script src=""selectcontact.js""></script>"
 Response.Write "<form>"
 Response.Write "<select name=""contactID"" onchange=""showCustomer(this.value)"">"

 Response.Write "<OPTION Value=""""></OPTION>"
 
 ' Loop through the recordset and populate the dropdown
 Do Until objRS.EOF = True
  contactID  = objRS("contactID").Value
  wlcfsName = objRS("Name").Value
  

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


Go to topic 40772

Return to index page 314
Return to index page 313
Return to index page 312
Return to index page 311
Return to index page 310
Return to index page 309
Return to index page 308
Return to index page 307
Return to index page 306
Return to index page 305