Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Build a form - function - combo/select boxes?

Reply
Thread Tools

Build a form - function - combo/select boxes?

 
 
Guest
Posts: n/a
 
      08-09-2004
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


 
Reply With Quote
 
 
 
 
Jeff Cochran
Guest
Posts: n/a
 
      08-09-2004
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, <(E-Mail Removed)> 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
>


 
Reply With Quote
 
 
 
 
Steven Burn
Guest
Posts: n/a
 
      08-09-2004
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!


<(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Chris Hohmann
Guest
Posts: n/a
 
      08-10-2004
<(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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
%>


 
Reply With Quote
 
Bullschmidt
Guest
Posts: n/a
 
      08-10-2004
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!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
<build-in function> incompatible with <function> Luke Python 5 01-31-2006 02:51 AM
Build a Better Blair (like Build a Better Bush, only better) Kenny Computer Support 0 05-06-2005 04:50 AM
write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function parameter komal C++ 6 01-25-2005 11:13 AM
SWsoft Acronis Disk Director Suite 9.0 Build 508, Acronis OS Selector 8.0 Build 917, Acronis Partition Expert 2003 Build 292, Acronis Power Utilities 2004 Build 502, F-SECURE.ANTI vIRUS.PROXY v1.10.17.WINALL, F-SECURE.ANTI vIRUS v5.50.10260 for CITRI vvcd Computer Support 0 09-25-2004 01:38 AM
How to build ASP.NET projects on a separate build machine? Vagif Abilov ASP .Net 2 07-07-2004 04:34 PM



Advertisments