Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Option list


Message #1 by "Jeffrey Ciesla" <JCiesla@o...> on Thu, 20 Apr 2000 12:27:51 -0400
I am in process of building an EDIT form. This gets information from a 

previous

ASP page and displays the values that are currently in the databaes. One 

of the

options (division), i want to display a drop-down list of all of the 

current divisions,

but have the value that the record contains be the selected value. Does

anyone have any advice?



I'm using FrontPage 2000 and I let it build the ASP page. I see the 

<option> tag

and I need to somehow reference <Option Selected=3D"incomming variable"> 

and

then let the rest of the list contain all other choices.



Is this even possible??





Thanks for your help,



Jeff Ciesla



Message #2 by "Ken Schaefer" <ken.s@a...> on Sat, 22 Apr 2000 23:21:08 +1000
Hi,



This will do what you want:

a) you'll need to create a recordset called objRS (eg create it implicitly

executing an SQL string on a connection object)

b) you'll need to replace the reference to objRS("field1") with the name of

your field from your database table that you want to compare to your listbox

values.



It basically uses a function to determine which value needs to be selected -

rather than writing lots of if...then...else code inline.



HTH



Cheers

Ken



<%

function fncSelectThis(intTemp)

    if objRS("field1") = intTemp then

        fncSelectThis = " selected"

    else

        fncSelectThis = " "

    end if

end function



'Open connection here

Set objRS = objConn.execute(strSQL)

%>



<%

If objRS.BOF and objRS.EOF then

    Response.Write("Your query returned no results")

Else

%>

<form>

    <select name="s1">

        <option value="1" <% =fncSelectThis(1)%>>1</option>

        <option value="2" <% =fncSelectThis(2)%>>2</option>

        <option value="3" <% =fncSelectThis(3)%>>3</option>

    </select>

</form>

<%

End if

objConn.close

set objConn = nothing

%>



----- Original Message -----

From: Jeffrey Ciesla <JCiesla@o...>

To: ASP Databases <asp_databases@p...>

Sent: Friday, April 21, 2000 2:27 AM

Subject: [asp_databases] Option list





I am in process of building an EDIT form. This gets information from a

previous

ASP page and displays the values that are currently in the databaes. One of

the

options (division), i want to display a drop-down list of all of the current

divisions,

but have the value that the record contains be the selected value. Does

anyone have any advice?



I'm using FrontPage 2000 and I let it build the ASP page. I see the <option>

tag

and I need to somehow reference <Option Selected="incomming variable"> and

then let the rest of the list contain all other choices.



Is this even possible??





Thanks for your help,



Jeff Ciesla





---

You are currently subscribed to asp_databases








Message #3 by Mangal Nagarkar <Mangal@i...> on Thu, 20 Apr 2000 12:01:17 -0500
Yes. This is certainly possible. I created the drop-down box on the fly

which shows values depending upon value from previous ASP page.



The code is something like this.



<% Dim oConn 

  dim SQLstring 

  dim rec, Zip_Code,City_Code

  set oConn=server.createObject("ADODB.Connection") 

  oConn.open "igawebdata" 

  set rec=server.createObject("ADODB.Recordset")



  SQLstring="select company,id_string from table_name where city ='"&

request.form("City") &"%%%'"



   set rec = oConn.Execute(SQLstring)



   set objcompany = rec("company")

  set objid = rec("id_string") %>



<select name="store_ID" size="1" style="font-variant:normal; text-align:

left" maxlength="30">

<% do until rec.eof

       Response.write "<option value="""& objid &""">"& objcompany

&"</option>" & Vbcrlf

Rec.movenext

Loop

Rec.close %>

</select> 

		



		-----Original Message-----

		From:	Jeffrey Ciesla 

		Sent:	Thursday, April 20, 2000 11:28 AM

		To:	ASP Databases

		Subject:	[asp_databases] Option list



		I am in process of building an EDIT form. This gets

information from a previous

		ASP page and displays the values that are currently in the

databaes. One of the

		options (division), i want to display a drop-down list of

all of the current divisions,

		but have the value that the record contains be the selected

value. Does 

		anyone have any advice? 



		I'm using FrontPage 2000 and I let it build the ASP page. I

see the <option> tag

		and I need to somehow reference <Option Selected="incomming

variable"> and

		then let the rest of the list contain all other choices.



		Is this even possible??





		Thanks for your help,



		Jeff Ciesla





		---

		You are currently subscribed to asp_databases 


$subst('Email.Unsub')

Message #4 by "Abhijit" <natuu@h...> on Fri, 21 Apr 2000 10:44:41 +0530
Ya this editable option is quite possible.

Let say database has value "Mango" for current selection and option has

three drop-down s with Mango , Apple and Banana.

Then  get value from database in field say fruit.



    <%if fruit ="Mango"Then

      <option value="1" selected>Mangot</option>

     <%else%>

      <option value="1">Mango</option>

     <%end if%>



 <%if fruit="Apple" Then%>

  <option value="2" selected>Apple</option>

 <%else%>

  <option value="2">Apple</option>

 <%end if%>



<%if fruit="banana" Then%>

  <option value="2" selected>banana</option>

 <%else%>

  <option value="2">banana</option>

 <%end if%>



This is possible solution for EDIt forms. I think may solve ur problem.



----- Original Message -----

From: Jeffrey Ciesla 

To: ASP Databases <asp_databases@p...>

Sent: Thursday, April 20, 2000 9:57 PM

Subject: [asp_databases] Option list





I am in process of building an EDIT form. This gets information from a

previous

ASP page and displays the values that are currently in the databaes. One of

the

options (division), i want to display a drop-down list of all of the current

divisions,

but have the value that the record contains be the selected value. Does

anyone have any advice?



I'm using FrontPage 2000 and I let it build the ASP page. I see the <option>

tag

and I need to somehow reference <Option Selected="incomming variable"> and

then let the rest of the list contain all other choices.



Is this even possible??





Thanks for your help,



Jeff Ciesla





---

You are currently subscribed to asp_databases






Message #5 by "Jeffrey Ciesla" <JCiesla@o...> on Tue, 25 Apr 2000 09:16:03 -0400
Instead of saying if fruit="Mango"    can I

put in a variable that has been passed by a

different page, let's say:

if fruit=3D"fruit_variable"



Jeff



Jeffrey P. Ciesla

Information Technology

Oglebay Norton Company



http://www.oglebaynorton.com



>>> 04/21/00 01:14AM >>>

Ya this editable option is quite possible.

Let say database has value "Mango" for current selection and option has

three drop-down s with Mango , Apple and Banana.

Then  get value from database in field say fruit.



    <%if fruit =3D"Mango"Then

      <option value=3D"1" selected>Mangot</option>

     <%else%>

      <option value=3D"1">Mango</option>

     <%end if%>



 <%if fruit=3D"Apple" Then%>

  <option value=3D"2" selected>Apple</option>

 <%else%>

  <option value=3D"2">Apple</option>

 <%end if%>



<%if fruit=3D"banana" Then%>

  <option value=3D"2" selected>banana</option>

 <%else%>

  <option value=3D"2">banana</option>

 <%end if%>



This is possible solution for EDIt forms. I think may solve ur problem.



----- Original Message -----

From: Jeffrey Ciesla

To: ASP Databases <asp_databases@p...>

Sent: Thursday, April 20, 2000 9:57 PM

Subject: [asp_databases] Option list





I am in process of building an EDIT form. This gets information from a

previous

ASP page and displays the values that are currently in the databaes. One 

of

the

options (division), i want to display a drop-down list of all of the 

current

divisions,

but have the value that the record contains be the selected value. Does

anyone have any advice?



I'm using FrontPage 2000 and I let it build the ASP page. I see the 

<option>

tag

and I need to somehow reference <Option Selected=3D"incomming variable"> 

and

then let the rest of the list contain all other choices.



Is this even possible??





Thanks for your help,



Jeff Ciesla


  Return to Index