473,396 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Build a form - function - combo/select boxes?

Is it possible to extend this function to dynamically create a combo boxes
from the db table....How would do this...I tried passing a 'Select' type to
the function but got a blank entry....Any ideas?

function BuildInput(sType,sName,sValue,iSize,iLength)
select case sType
case "text":
BuildInput = "<INPUT TYPE=""text"" NAME=""" & sName & """ VALUE=""" &
sValue & """ SIZE=""" & iSize & """ MAXLENGTH=""" & iLength & """>"
case "password"
BuildInput = "<INPUT TYPE=""password"" NAME=""" & sName & """ VALUE=""" &
sValue & """ SIZE=""" & iSize & """ MAXLENGTH=""" & iLength & """>"
case "submit"
BuildInput = "<INPUT TYPE=""submit"" NAME=""" & sName & """ VALUE=""" &
sValue & """>"
end select
end function

Response.Write(BuildForm("edituser","post"))

Response.Write(BuildInput("hidden","u_id",Request. QueryString("u_id"),"","")
)
Response.Write("<TABLE>")
Response.Write("<TR><TD>User Name</TD><TD>" & &
BuildInput("text","u_name",escapeString(oRS.fields ("u_name")),20,50) &
"</TD></TR>")
Response.Write("<TR><TD>Password</TD><TD>" &
BuildInput("text","u_password",oRS.fields("u_passw ord"),12,12) &
"</TD></TR>")
Response.Write("<TR><TD>First Name</TD><TD>" &
BuildInput("text","u_firstname",escapeString(oRS.f ields("u_firstname")),20,5
0) & "</TD></TR>")
Response.Write("<TR><TD>Last Name</TD><TD>" &
BuildInput("text","u_lastname",escapeString(oRS.fi elds("u_lastname")),20,50)
& "</TD></TR>")
Response.Write("<TR><TD>Email Name</TD><TD>" &
BuildInput("text","u_email",escapeString(oRS.field s("u_email")),20,50) &
"</TD></TR>")
Response.Write("<TR><TD COLSPAN=2>" &
BuildInput("submit","action",ACTIONSAVE,"","") & "</TD></TR>")
Response.Write("</TABLE>"
Many thanks
Jason
Jul 19 '05 #1
5 2074
Is this what you're trying to do?

http://www.devasp.com/samples/populatedropdown.asp

Jeff

On Mon, 9 Aug 2004 13:10:24 -0400, <ja***@catamaranco.com> wrote:
Is it possible to extend this function to dynamically create a combo boxes
from the db table....How would do this...I tried passing a 'Select' type to
the function but got a blank entry....Any ideas?

function BuildInput(sType,sName,sValue,iSize,iLength)
select case sType
case "text":
BuildInput = "<INPUT TYPE=""text"" NAME=""" & sName & """ VALUE=""" &
sValue & """ SIZE=""" & iSize & """ MAXLENGTH=""" & iLength & """>"
case "password"
BuildInput = "<INPUT TYPE=""password"" NAME=""" & sName & """ VALUE=""" &
sValue & """ SIZE=""" & iSize & """ MAXLENGTH=""" & iLength & """>"
case "submit"
BuildInput = "<INPUT TYPE=""submit"" NAME=""" & sName & """ VALUE=""" &
sValue & """>"
end select
end function

Response.Write(BuildForm("edituser","post"))

Response.Write(BuildInput("hidden","u_id",Request .QueryString("u_id"),"","")
)
Response.Write("<TABLE>")
Response.Write("<TR><TD>User Name</TD><TD>" & &
BuildInput("text","u_name",escapeString(oRS.field s("u_name")),20,50) &
"</TD></TR>")
Response.Write("<TR><TD>Password</TD><TD>" &
BuildInput("text","u_password",oRS.fields("u_pass word"),12,12) &
"</TD></TR>")
Response.Write("<TR><TD>First Name</TD><TD>" &
BuildInput("text","u_firstname",escapeString(oRS. fields("u_firstname")),20,5
0) & "</TD></TR>")
Response.Write("<TR><TD>Last Name</TD><TD>" &
BuildInput("text","u_lastname",escapeString(oRS.f ields("u_lastname")),20,50)
& "</TD></TR>")
Response.Write("<TR><TD>Email Name</TD><TD>" &
BuildInput("text","u_email",escapeString(oRS.fiel ds("u_email")),20,50) &
"</TD></TR>")
Response.Write("<TR><TD COLSPAN=2>" &
BuildInput("submit","action",ACTIONSAVE,"","") & "</TD></TR>")
Response.Write("</TABLE>"
Many thanks
Jason


Jul 19 '05 #2
I'm curious about why you doing this this way?, what exactly is it your
trying to do?

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
<ja***@catamaranco.com> wrote in message
news:#o*************@TK2MSFTNGP11.phx.gbl...
Is it possible to extend this function to dynamically create a combo boxes
from the db table....How would do this...I tried passing a 'Select' type to the function but got a blank entry....Any ideas?

function BuildInput(sType,sName,sValue,iSize,iLength)
select case sType
case "text":
BuildInput = "<INPUT TYPE=""text"" NAME=""" & sName & """ VALUE=""" &
sValue & """ SIZE=""" & iSize & """ MAXLENGTH=""" & iLength & """>"
case "password"
BuildInput = "<INPUT TYPE=""password"" NAME=""" & sName & """ VALUE=""" & sValue & """ SIZE=""" & iSize & """ MAXLENGTH=""" & iLength & """>"
case "submit"
BuildInput = "<INPUT TYPE=""submit"" NAME=""" & sName & """ VALUE=""" &
sValue & """>"
end select
end function

Response.Write(BuildForm("edituser","post"))

Response.Write(BuildInput("hidden","u_id",Request. QueryString("u_id"),"","") )
Response.Write("<TABLE>")
Response.Write("<TR><TD>User Name</TD><TD>" & &
BuildInput("text","u_name",escapeString(oRS.fields ("u_name")),20,50) &
"</TD></TR>")
Response.Write("<TR><TD>Password</TD><TD>" &
BuildInput("text","u_password",oRS.fields("u_passw ord"),12,12) &
"</TD></TR>")
Response.Write("<TR><TD>First Name</TD><TD>" &
BuildInput("text","u_firstname",escapeString(oRS.f ields("u_firstname")),20,5 0) & "</TD></TR>")
Response.Write("<TR><TD>Last Name</TD><TD>" &
BuildInput("text","u_lastname",escapeString(oRS.fi elds("u_lastname")),20,50) & "</TD></TR>")
Response.Write("<TR><TD>Email Name</TD><TD>" &
BuildInput("text","u_email",escapeString(oRS.field s("u_email")),20,50) &
"</TD></TR>")
Response.Write("<TR><TD COLSPAN=2>" &
BuildInput("submit","action",ACTIONSAVE,"","") & "</TD></TR>")
Response.Write("</TABLE>"
Many thanks
Jason

Jul 19 '05 #3
I'm trying to build a form that automatically builds itself from the data
types and fields within the sql server database.......

Thanks
Jason
"Steven Burn" <pv*@noyb.com> wrote in message
news:OF**************@tk2msftngp13.phx.gbl...
I'm curious about why you doing this this way?, what exactly is it your
trying to do?

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
<ja***@catamaranco.com> wrote in message
news:#o*************@TK2MSFTNGP11.phx.gbl...
Is it possible to extend this function to dynamically create a combo boxes from the db table....How would do this...I tried passing a 'Select' type to
the function but got a blank entry....Any ideas?

function BuildInput(sType,sName,sValue,iSize,iLength)
select case sType
case "text":
BuildInput = "<INPUT TYPE=""text"" NAME=""" & sName & """ VALUE=""" &
sValue & """ SIZE=""" & iSize & """ MAXLENGTH=""" & iLength & """>"
case "password"
BuildInput = "<INPUT TYPE=""password"" NAME=""" & sName & """ VALUE=""" &
sValue & """ SIZE=""" & iSize & """ MAXLENGTH=""" & iLength & """>"
case "submit"
BuildInput = "<INPUT TYPE=""submit"" NAME=""" & sName & """ VALUE="""

& sValue & """>"
end select
end function

Response.Write(BuildForm("edituser","post"))

Response.Write(BuildInput("hidden","u_id",Request. QueryString("u_id"),"","")
)
Response.Write("<TABLE>")
Response.Write("<TR><TD>User Name</TD><TD>" & &
BuildInput("text","u_name",escapeString(oRS.fields ("u_name")),20,50) &
"</TD></TR>")
Response.Write("<TR><TD>Password</TD><TD>" &
BuildInput("text","u_password",oRS.fields("u_passw ord"),12,12) &
"</TD></TR>")
Response.Write("<TR><TD>First Name</TD><TD>" &

BuildInput("text","u_firstname",escapeString(oRS.f ields("u_firstname")),20,5
0) & "</TD></TR>")
Response.Write("<TR><TD>Last Name</TD><TD>" &

BuildInput("text","u_lastname",escapeString(oRS.fi elds("u_lastname")),20,50)
& "</TD></TR>")
Response.Write("<TR><TD>Email Name</TD><TD>" &
BuildInput("text","u_email",escapeString(oRS.field s("u_email")),20,50) &
"</TD></TR>")
Response.Write("<TR><TD COLSPAN=2>" &
BuildInput("submit","action",ACTIONSAVE,"","") & "</TD></TR>")
Response.Write("</TABLE>"
Many thanks
Jason


Jul 19 '05 #4
<ja***@catamaranco.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
Is it possible to extend this function to dynamically create a combo boxes
from the db table....How would do this...I tried passing a 'Select' type to the function but got a blank entry....Any ideas?


No, but here are two (2) functions I use. DBCFS is for single-select mode
select controls, DBLSS is for multi-select mode select controls.

<%
Function DBCFS(strConn,strSQL,varSelectedKey)
'I/O:
'--> strConn : Connection String
'--> strSQL : SQL Statement OR "Table" Name
'--> varSelectedKey : Variant that identifies which option should be
selected
'Notes:
'The function expects strSQL to return at least two(2) columns.
'Column 1 will be used to populate the value attribute of the option tag
'Column 2 will be used to populate the content of the option tag, ie. what
gets displayed

'Determine command type
Dim re, lngOptions
Set re = New RegExp
re.Pattern = "^\s*(SELECT|EXEC)"
re.IgnoreCase = True
If re.Test(strSQL) Then
lngOptions = &H1 'Command Text
Else
lngOptions = &H2 'Table
End If

'Get the data
Dim conn, rs, arr
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open strConn
Set rs = conn.Execute(strSQL,,lngOptions)
If Not rs.EOF Then arr = rs.GetRows()
rs.Close : Set rs = Nothing
conn.Close : Set conn = Nothing

'Build the option tags
Dim j,o
o=""
If IsArray(arr) Then
For j = 0 to UBound(arr,2)
o=o & "<option value=""" & Server.HTMLEncode(arr(0,j)) & """"
If arr(0,j) = varSelectedKey Then
o=o & " selected"
End If
o=o & ">" & Server.HTMLEncode(arr(1,j)) & "</option>" & vbCRLF
Next
Else
o=o & "<option>[No Option Data]</option>"
End If
DBCFS = o
End Function

Function DBLSS(strConn,strSQL)
'I/O:
'--> strConn : Connection String
'--> strSQL : SQL Statement OR "Table" Name
'Notes:
'The function expects strSQL to return at least three(3) columns.
'Column 1 will be used to populate the value attribute of the option tag
'Column 2 will be used to populate the content of the option tag, ie. what
gets displayed
'Column 3 determines if the select attribute should be set for the option
tag

'Determine command type
Dim re, lngOptions
Set re = New RegExp
re.Pattern = "^\s*(SELECT|EXEC)"
re.IgnoreCase = True
If re.Test(strSQL) Then
lngOptions = &H1 'Command Text
Else
lngOptions = &H2 'Table
End If

'Get data
Dim conn, rs, arr
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open strConn
Set rs = conn.Execute(strSQL,,lngOptions)
If Not rs.EOF Then arr = rs.GetRows()
rs.Close : Set rs = Nothing
conn.Close : Set conn = Nothing

'Build option tags
Dim j,o
o=""
If IsArray(arr) Then
For j = 0 to UBound(arr,2)
o=o & "<option value=""" & Server.HTMLEncode(arr(0,j)) & """"
If arr(2,j) Then
o=o & " selected"
End If
o=o & ">" & Server.HTMLEncode(arr(1,j)) & "</option>"
Next
Else
o=o & "<option>" & strSQL & "</option>"
End If
DBLSS = o
End Function
%>
Jul 19 '05 #5
Perhaps this may hopefully give you some ideas and it's got a
downloadable sample:

Classic ASP Design Tips - Fill a Listbox Possibly With Multiple Columns
http://www.bullschmidt.com/devtip-filllistbox.asp

Best regards,
J. Paul Schmidt, Freelance ASP Web Developer
http://www.Bullschmidt.com
Classic ASP Design Tips, ASP Web Database Sample (Freely Downloadable)
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is...
1
by: FZ | last post by:
Hi Gang, I was wondering if a generous person might be able to walk me through what I believe is a pretty simple task. I actually have significant Access experience, but I haven't done it in...
2
by: Sean | last post by:
Greetings all, I am attempting to make a form that will filter through several tables that (I believe) have refretial integrity. I am pulling data from several tables into the form and i would...
1
by: edworboys | last post by:
I have a form (Prospect) with a subform (Document). The result I am looking for is this: The user selects a prospect which is made up of Prospect Name, Country, Company and Prospect Type. They...
12
by: Tom | last post by:
Hello, I have a database of employee data in access and I am trying to create a form with combo boxes for criteria (ex. gender, office, position, etc.) that let the user select criteria from...
2
by: ddog | last post by:
I have a form with 3 text fields (one of which is a zip code) and 5 combo boxes. The combo boxes are all set with the first value as 'selected' when the page is first displayed. The 3 text fields...
1
by: Dave | last post by:
Hello all, First I'd like to apologize...This post was meant to be put in my previous post, but I tried many times without success to reply within my previous post. Now here goes... I have a...
2
by: Shawn Yates | last post by:
I am creating a Zip Code search tool. I have a Table with every zip code and its corresponding city and state. I have also created an input table that allows the user to input cities and states....
4
by: SKelso | last post by:
I created a database in Access 2003 that contains an unbound search form with several combo boxes. Each combo box is populated with entries from the appropriate table. I want to allow the user to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.