|
 |
asp_databases thread: RE: using querystring to set SELECTED propert
y on combo box
Message #1 by Colin.Montgomery@C... on Fri, 12 Apr 2002 10:37:35 +0100
|
|
yeah, they're not in a database - that'd be too easy!
Thanks Peter, I really appreciate your help.
Col
-----Original Message-----
From: Peter Foti (PeterF) [mailto:PeterF@S...]
Sent: 11 April 2002 19:19
To: ASP Databases
Subject: [asp_databases] RE: using querystring to set SELECTED property
on combo box
So the office values aren't stored in a database then I take it?
<%
' Create the array
Dim libraryArray(6,2)
' Fill in the array
libraryArray(0,0) = "ALL"
libraryArray(0,1) = "ALL"
libraryArray(1,0) = "AMSTERDAM"
libraryArray(1,1) = "Amsterdam Office"
libraryArray(2,0) = "LONDON"
libraryArray(2,1) = "London Office"
libraryArray(3,0) = "NEW_YORK"
libraryArray(3,1) = "New York Office"
libraryArray(4,0) = "OTHER_INTL"
libraryArray(4,1) = "Other Offices"
libraryArray(5,0) = "WASHINGTON"
libraryArray(5,1) = "Washington Office"
' Write the select open tag
Response.Write("<SELECT NAME=""library"" >" & vbCrLf)
' Loop through the array
for i = 0 to 5
Response.Write("<OPTION VALUE=""")
Response.Write(myArray(i,0))
' Compare the value in the array with the query string
If myArray(i,0) = Request("library") Then
Response.Write(""" SELECTED>")
Else
Response.Write(""">")
End If
Response.Write(myArray(i,1))
Response.Write(vbCrLf)
next
' Write the select close tag
Response.Write("</SELECT>" & vbCrLf)
%>
Hope this helps.
Pete
> -----Original Message-----
> From: Colin.Montgomery@C...
> [mailto:Colin.Montgomery@C...]
> Sent: Thursday, April 11, 2002 1:42 PM
> To: ASP Databases
> Subject: [asp_databases] using querystring to set SELECTED property on
> combo box
>
>
> Hi,
>
> I want to be able to pass in a variable to set the
> default/selected value of
> a combo box, using the querystring. The combo box contains a list of
> offices, where the HTML would be:
>
> <SELECT NAME="library" >
> <OPTION SELECTED VALUE="ALL">ALL
> <OPTION VALUE="AMSTERDAM">Amsterdam Office
> <OPTION VALUE="LONDON">London Office
> <OPTION VALUE="NEW_YORK">New York Office
> <OPTION VALUE="OTHER_INTL">Other Offices
> <OPTION VALUE="WASHINGTON">Washington Office
> </SELECT>
>
> As you can see the text and the value are different in each case.
>
> I'm assuming the only way to accomplish this is to store
> everthing in a 2
> dimensional array and loop through it, each time testing to see if the
> current value = strOffice (taken from the querystring). If
> so insert the
> SELECTED attribute.
>
> I think it's just cos i'm crap when it comes to arrays, but I
> can't figure
> out how to do this without writing masses of sh!tty code!
> Anybody help?
> (i've got another combo box to set in the same way on the
> same page, which
> has about 140 values).
>
> Any help much appreciated,
> Col
>
>
>
> *******
>
> This message and any attachment are confidential and may be
> privileged or otherwise protected from disclosure. If you
> are not the intended recipient, please telephone or email the
> sender and delete this message and any attachment from your
> system. If you are not the intended recipient you must not
> copy this message or attachment or disclose the contents to
> any other person.
>
> For further information about Clifford Chance please see our
> website at http://www.cliffordchance.com or refer to any
> Clifford Chance office.
>
>
>
Message #2 by "Peter Foti (PeterF)" <PeterF@S...> on Thu, 11 Apr 2002 14:18:45 -0400
|
|
So the office values aren't stored in a database then I take it?
<%
' Create the array
Dim libraryArray(6,2)
' Fill in the array
libraryArray(0,0) = "ALL"
libraryArray(0,1) = "ALL"
libraryArray(1,0) = "AMSTERDAM"
libraryArray(1,1) = "Amsterdam Office"
libraryArray(2,0) = "LONDON"
libraryArray(2,1) = "London Office"
libraryArray(3,0) = "NEW_YORK"
libraryArray(3,1) = "New York Office"
libraryArray(4,0) = "OTHER_INTL"
libraryArray(4,1) = "Other Offices"
libraryArray(5,0) = "WASHINGTON"
libraryArray(5,1) = "Washington Office"
' Write the select open tag
Response.Write("<SELECT NAME=""library"" >" & vbCrLf)
' Loop through the array
for i = 0 to 5
Response.Write("<OPTION VALUE=""")
Response.Write(myArray(i,0))
' Compare the value in the array with the query string
If myArray(i,0) = Request("library") Then
Response.Write(""" SELECTED>")
Else
Response.Write(""">")
End If
Response.Write(myArray(i,1))
Response.Write(vbCrLf)
next
' Write the select close tag
Response.Write("</SELECT>" & vbCrLf)
%>
Hope this helps.
Pete
> -----Original Message-----
> From: Colin.Montgomery@C...
> [mailto:Colin.Montgomery@C...]
> Sent: Thursday, April 11, 2002 1:42 PM
> To: ASP Databases
> Subject: [asp_databases] using querystring to set SELECTED property on
> combo box
>
>
> Hi,
>
> I want to be able to pass in a variable to set the
> default/selected value of
> a combo box, using the querystring. The combo box contains a list of
> offices, where the HTML would be:
>
> <SELECT NAME="library" >
> <OPTION SELECTED VALUE="ALL">ALL
> <OPTION VALUE="AMSTERDAM">Amsterdam Office
> <OPTION VALUE="LONDON">London Office
> <OPTION VALUE="NEW_YORK">New York Office
> <OPTION VALUE="OTHER_INTL">Other Offices
> <OPTION VALUE="WASHINGTON">Washington Office
> </SELECT>
>
> As you can see the text and the value are different in each case.
>
> I'm assuming the only way to accomplish this is to store
> everthing in a 2
> dimensional array and loop through it, each time testing to see if the
> current value = strOffice (taken from the querystring). If
> so insert the
> SELECTED attribute.
>
> I think it's just cos i'm crap when it comes to arrays, but I
> can't figure
> out how to do this without writing masses of sh!tty code!
> Anybody help?
> (i've got another combo box to set in the same way on the
> same page, which
> has about 140 values).
>
> Any help much appreciated,
> Col
>
>
>
> *******
>
> This message and any attachment are confidential and may be
> privileged or otherwise protected from disclosure. If you
> are not the intended recipient, please telephone or email the
> sender and delete this message and any attachment from your
> system. If you are not the intended recipient you must not
> copy this message or attachment or disclose the contents to
> any other person.
>
> For further information about Clifford Chance please see our
> website at http://www.cliffordchance.com or refer to any
> Clifford Chance office.
>
>
>
Message #3 by Colin.Montgomery@C... on Thu, 11 Apr 2002 18:42:14 +0100
|
|
Hi,
I want to be able to pass in a variable to set the default/selected value of
a combo box, using the querystring. The combo box contains a list of
offices, where the HTML would be:
<SELECT NAME="library" >
<OPTION SELECTED VALUE="ALL">ALL
<OPTION VALUE="AMSTERDAM">Amsterdam Office
<OPTION VALUE="LONDON">London Office
<OPTION VALUE="NEW_YORK">New York Office
<OPTION VALUE="OTHER_INTL">Other Offices
<OPTION VALUE="WASHINGTON">Washington Office
</SELECT>
As you can see the text and the value are different in each case.
I'm assuming the only way to accomplish this is to store everthing in a 2
dimensional array and loop through it, each time testing to see if the
current value = strOffice (taken from the querystring). If so insert the
SELECTED attribute.
I think it's just cos i'm crap when it comes to arrays, but I can't figure
out how to do this without writing masses of sh!tty code! Anybody help?
(i've got another combo box to set in the same way on the same page, which
has about 140 values).
Any help much appreciated,
Col
*******
This message and any attachment are confidential and may be privileged or otherwise protected from disclosure. If you are not the
intended recipient, please telephone or email the sender and delete this message and any attachment from your system. If you are
not the intended recipient you must not copy this message or attachment or disclose the contents to any other person.
For further information about Clifford Chance please see our website at http://www.cliffordchance.com or refer to any Clifford
Chance office.
|
|
 |