Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Dynamic Drop Down List-Menu box


Message #1 by "Ewout" <raisy@w...> on Tue, 16 Oct 2001 13:00:43
I'm having an update form with a Dynamic populated List/Menu. It grabs

nicely the values from the database and selects the appropriate category

that I entered during the insert of the record. But there are situations

where I insert a record WITHOUT a category and leave this field blank



(I've done this in the Insert Page by inserting above the populated drop

down Box putting in an option that says the following:

<option value="">No Town</option>)



Now in the update Record page, I receive the error:

Error Type:

Microsoft VBScript runtime (0x800A005E)

Invalid use of Null: 'CStr'

/event-update.asp, line 881



I understand that it wants to select a value that does not exist, but how 

do I integrate this NULL value in the coding?, so if there is no town 

available in the record it will just select *NO TOWN*?



The coding for the page is as follows:

                    <select name="townid">

                      <option value="">No Town</option>

                      <%

While (NOT rsTowns.EOF)

%>

                      <option

value="<%=(rsTowns.Fields.Item("townid").Value)%>" <%if

(CStr(rsTowns.Fields.Item("townid").Value) 

CStr(rseventupdate.Fields.Item("townid").Value)) then

Response.Write("SELECTED") :

Response.Write("")%>><%=(rsTowns.Fields.Item("town").Value)%></option>

                      <%

  rsTowns.MoveNext()

Wend

If (rsTowns.CursorType > 0) Then

  rsTowns.MoveFirst

Else

  rsTowns.Requery

End If

%>

                    </select>



I use Macromedia Ultradev for this, but obviously that is not sufficient 

anymore for what I do, could anyone show me how I need to code this in ASP?



Thank you very much for your time



Evan



Message #2 by "Tim Morford" <tmorford@n...> on Tue, 16 Oct 2001 08:38:21 -0400
<%

	if (CStr(rsTowns.Fields.Item("townid").Value) = "" THEN

		Response.write ("<OPTION>No Town</OPTION>")

	Else

		Response.write ("<OPTION VALUE=" & rsTowns.Fields.Item("townid").Value &

"> & _

			" & rsTowns.Fields.Item("town").Value & "</OPTION>")

	End If

%>



That should work



Tim Morford

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

From: Ewout [mailto:raisy@w...]

Sent: Tuesday, October 16, 2001 1:01 PM

To: ASP Web HowTo

Subject: [asp_web_howto] Dynamic Drop Down List-Menu box





I'm having an update form with a Dynamic populated List/Menu. It grabs

nicely the values from the database and selects the appropriate category

that I entered during the insert of the record. But there are situations

where I insert a record WITHOUT a category and leave this field blank



(I've done this in the Insert Page by inserting above the populated drop

down Box putting in an option that says the following:

<option value="">No Town</option>)



Now in the update Record page, I receive the error:

Error Type:

Microsoft VBScript runtime (0x800A005E)

Invalid use of Null: 'CStr'

/event-update.asp, line 881



I understand that it wants to select a value that does not exist, but how

do I integrate this NULL value in the coding?, so if there is no town

available in the record it will just select *NO TOWN*?



The coding for the page is as follows:

                    <select name="townid">

                      <option value="">No Town</option>

                      <%

While (NOT rsTowns.EOF)

%>

                      <option

value="<%=(rsTowns.Fields.Item("townid").Value)%>" <%if

(CStr(rsTowns.Fields.Item("townid").Value) 

CStr(rseventupdate.Fields.Item("townid").Value)) then

Response.Write("SELECTED") :

Response.Write("")%>><%=(rsTowns.Fields.Item("town").Value)%></option>

                      <%

  rsTowns.MoveNext()

Wend

If (rsTowns.CursorType > 0) Then

  rsTowns.MoveFirst

Else

  rsTowns.Requery

End If

%>

                    </select>



I use Macromedia Ultradev for this, but obviously that is not sufficient

anymore for what I do, could anyone show me how I need to code this in ASP?



Thank you very much for your time



Evan








$subst('Email.Unsub')





Message #3 by - <raisy@w...> on Tue, 16 Oct 2001 14:48:32 +0200
Hi Tom, thank you very much for your quick reply!!!!!



Allthough i'm not sure how I will integrate the automatic generated 

dropdown box, but I'll figure out something! thank you for getting me on 

the way



Evan





At 08:38 AM 10/16/2001 -0400, you wrote:

><%

>         if (CStr(rsTowns.Fields.Item("townid").Value) = "" THEN

>                 Response.write ("<OPTION>No Town</OPTION>")

>         Else

>                 Response.write ("<OPTION VALUE=" & 

> rsTowns.Fields.Item("townid").Value &

>"> & _

>                         " & rsTowns.Fields.Item("town").Value & "</OPTION>")

>         End If

>%>

>

>That should work

>

>Tim Morford

>-----Original Message-----

>From: Ewout [mailto:raisy@w...]

>Sent: Tuesday, October 16, 2001 1:01 PM

>To: ASP Web HowTo

>Subject: [asp_web_howto] Dynamic Drop Down List-Menu box

>

>

>I'm having an update form with a Dynamic populated List/Menu. It grabs

>nicely the values from the database and selects the appropriate category

>that I entered during the insert of the record. But there are situations

>where I insert a record WITHOUT a category and leave this field blank

>

>(I've done this in the Insert Page by inserting above the populated drop

>down Box putting in an option that says the following:

><option value="">No Town</option>)

>

>Now in the update Record page, I receive the error:

>Error Type:

>Microsoft VBScript runtime (0x800A005E)

>Invalid use of Null: 'CStr'

>/event-update.asp, line 881

>

>I understand that it wants to select a value that does not exist, but how

>do I integrate this NULL value in the coding?, so if there is no town

>available in the record it will just select *NO TOWN*?

>

>The coding for the page is as follows:

>                     <select name="townid">

>                       <option value="">No Town</option>

>                       <%

>While (NOT rsTowns.EOF)

>%>

>                       <option

>value="<%=(rsTowns.Fields.Item("townid").Value)%>" <%if

>(CStr(rsTowns.Fields.Item("townid").Value) 

>CStr(rseventupdate.Fields.Item("townid").Value)) then

>Response.Write("SELECTED") :

>Response.Write("")%>><%=(rsTowns.Fields.Item("town").Value)%></option>

>                       <%

>   rsTowns.MoveNext()

>Wend

>If (rsTowns.CursorType > 0) Then

>   rsTowns.MoveFirst

>Else

>   rsTowns.Requery

>End If

>%>

>                     </select>

>

>I use Macromedia Ultradev for this, but obviously that is not sufficient

>anymore for what I do, could anyone show me how I need to code this in ASP?

>

>Thank you very much for your time

>

>Evan
Message #4 by "Tim Morford" <tmorford@n...> on Tue, 16 Oct 2001 09:07:54 -0400
Set Con = Server.CreateObject("ADODB.Connection")

sql = "SELECT Town, TownID FROM Town_Table"

Set objRS = Con.Execute(sql)



Response.Write("<SELECT NAME=""Towns"">")



While Not objRS.EOF

If objRS("TownID") = "" THEN

	Response.write("<OPTION>No Town</OPTION>")

Else

	Response.write("<OPTION VALUE=" & objRS("TownID") & ">")

	Response.write("" & objRS("Town") & " </OPTION>")

objRS.MoveNext

Wend



</SELECT>



I that should give you all that you need, There might be some type o's but

hey its early still.



Tim Morford



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

From: Ewout [mailto:raisy@w...]

Sent: Tuesday, October 16, 2001 1:01 PM

To: ASP Web HowTo

Subject: [asp_web_howto] Dynamic Drop Down List-Menu box





I'm having an update form with a Dynamic populated List/Menu. It grabs

nicely the values from the database and selects the appropriate category

that I entered during the insert of the record. But there are situations

where I insert a record WITHOUT a category and leave this field blank



(I've done this in the Insert Page by inserting above the populated drop

down Box putting in an option that says the following:

<option value="">No Town</option>)



Now in the update Record page, I receive the error:

Error Type:

Microsoft VBScript runtime (0x800A005E)

Invalid use of Null: 'CStr'

/event-update.asp, line 881



I understand that it wants to select a value that does not exist, but how

do I integrate this NULL value in the coding?, so if there is no town

available in the record it will just select *NO TOWN*?



The coding for the page is as follows:

                    <select name="townid">

                      <option value="">No Town</option>

                      <%

While (NOT rsTowns.EOF)

%>

                      <option

value="<%=(rsTowns.Fields.Item("townid").Value)%>" <%if

(CStr(rsTowns.Fields.Item("townid").Value) 

CStr(rseventupdate.Fields.Item("townid").Value)) then

Response.Write("SELECTED") :

Response.Write("")%>><%=(rsTowns.Fields.Item("town").Value)%></option>

                      <%

  rsTowns.MoveNext()

Wend

If (rsTowns.CursorType > 0) Then

  rsTowns.MoveFirst

Else

  rsTowns.Requery

End If

%>

                    </select>



I use Macromedia Ultradev for this, but obviously that is not sufficient

anymore for what I do, could anyone show me how I need to code this in ASP?



Thank you very much for your time



Evan
Message #5 by - <raisy@w...> on Tue, 16 Oct 2001 15:14:33 +0200
you are awesome Tim



Thank you very very much :o)))))))))

  Return to Index