Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 13th, 2006, 12:35 PM
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.




 
Old April 13th, 2006, 02:50 PM
Registered User
 
Join Date: Apr 2006
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP form to XML form confusion jroxit Classic ASP Basics 1 October 24th, 2008 03:20 PM
send parameters from asp page to an asp.net form hastikeyvan ASP.NET 1.0 and 1.1 Basics 2 March 29th, 2008 01:32 AM
Converting an HTML Form to ASP.Net Form k_alidxb75 ASP.NET 1.x and 2.0 Application Design 0 November 30th, 2006 03:26 AM
asp.net form to act like old asp form namaste Classic ASP Basics 0 July 25th, 2003 01:29 AM
asp.net form to act like old asp form namaste VB How-To 0 July 25th, 2003 01:15 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.