Textbox value validation using database table

Hello,

I've done this with drop-downs where I loop through a recordset,
populated another drop-down and so forth. But I think this should be
easier, but I'm not sure. I have a table with states, cities and rates.
What I need to do is when a user selects a certain state from a drop
down, and then enters the city in a text box, the name entered in the
city is validated against the values in the table (WHERE city = XXX).
Then, there is another readonly field that I need populated with the
rates value associated with that city. If someone could show me an
example of what I'm trying to do it would be greatly appreciated.

Thanks in advance,
KP
Kermit Piper [ Fr, 17 März 2006 02:37 ] [ ID #1234246 ]

Re: Textbox value validation using database table

"Kermit Piper" wrote in message
news:1142559430.838419.173270 [at] z34g2000cwc.googlegroups.com.. .
: I've done this with drop-downs where I loop through a recordset,
: populated another drop-down and so forth. But I think this should be
: easier, but I'm not sure. I have a table with states, cities and rates.
: What I need to do is when a user selects a certain state from a drop
: down, and then enters the city in a text box, the name entered in the
: city is validated against the values in the table (WHERE city = XXX).
: Then, there is another readonly field that I need populated with the
: rates value associated with that city. If someone could show me an
: example of what I'm trying to do it would be greatly appreciated.

Why not just show the cities and let them select?

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Roland Hall [ Fr, 17 März 2006 04:58 ] [ ID #1234247 ]

Re: Textbox value validation using database table

This is possible, i have done it a few times using an ASP with a
VBscript function. I can't think of any tutorials for this however i
will send you an example


Roland Hall wrote:
> "Kermit Piper" wrote in message
> news:1142559430.838419.173270 [at] z34g2000cwc.googlegroups.com.. .
> : I've done this with drop-downs where I loop through a recordset,
> : populated another drop-down and so forth. But I think this should be
> : easier, but I'm not sure. I have a table with states, cities and rates.
> : What I need to do is when a user selects a certain state from a drop
> : down, and then enters the city in a text box, the name entered in the
> : city is validated against the values in the table (WHERE city = XXX).
> : Then, there is another readonly field that I need populated with the
> : rates value associated with that city. If someone could show me an
> : example of what I'm trying to do it would be greatly appreciated.
>
> Why not just show the cities and let them select?
>
> --
> Roland Hall
> /* This information is distributed in the hope that it will be useful, but
> without any warranty; without even the implied warranty of merchantability
> or fitness for a particular purpose. */
> Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
> WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
> MSDN Library - http://msdn.microsoft.com/library/default.asp
nvanhaaster [ Fr, 17 März 2006 19:45 ] [ ID #1234250 ]

Re: Textbox value validation using database table

Here is a rough example, as you see as soon as you change the City text
box it will resend the data back to the server and then display the
rate back. You notice i made a call to rsRate() replace this with your
Database string, and also make sure that you set up your DB connection.
I haven't really tested in so there may be some small issues but it
will give you somewhere to start.

WATCH FOR WORD WRAP

<html>
<head>
<SCRIPT language=vbscript>
Function rateUpdate()
Dim cState
Dim cText
cState = document.rform.cState.Value
cText = document.rform.cText.Value
window.location.href "/rateview.asp?cState=" & cState & "&cText=" &
cText

end function
</SCRIPT>
</head>
<body>
<%
Dim cState
Dim cText
Dim rate

cState = Request.QueryString("cState")
cText = Request.QueryString("cText")

response.write "<Form name=rView>"
response.write "State : <select name=sState size=1>"

Do While Not rsRate.EOF 'loop through states and select the apporiate
state the user has selected
If rsRate("State") = cState then
response.write "<option value=" & rsRate("State") & " SELECTED>" &
rsRate("State") & "</option>"
else
response.write "<option value=" & rsRate("State") & ">" &
rsRate("State") & "</option>"
end if
rsRate.MoveNext
Loop

response.write "City: <input type=text name=sText value=" & cText & "
onCHANGE=rateUpdate()>" 'Display city and fill in if user has entered
data

If cState <> "" AND cText <> "" then
rsRate.MoveFirst
Do While Not rsRate.EOF
If rsRate("State") = cState AND rsRate("City") = cText Then
response.write "Rate : <input type=disabled name=rate value=" &
rsRate("Rate") & ">"
End If
rsRate.MoveNext
Loop
End If
rsRate.Close
response.write "</form>"
%>
</body>
nvanhaaster [ Fr, 17 März 2006 20:08 ] [ ID #1234251 ]

Re: Textbox value validation using database table

some of this may help

http://www.powerasp.com/content/code-snippets/forms-populate -drop-down-menu.asp

http://www.powerasp.com/content/code-snippets/forms-populate -check-box.asp\

http://www.powerasp.com/content/code-snippets/forms-populate -radio-buttons.asp


"Kermit Piper" <dice_response [at] hotmail.com> wrote in message
news:1142559430.838419.173270 [at] z34g2000cwc.googlegroups.com.. .
> Hello,
>
> I've done this with drop-downs where I loop through a recordset,
> populated another drop-down and so forth. But I think this should be
> easier, but I'm not sure. I have a table with states, cities and rates.
> What I need to do is when a user selects a certain state from a drop
> down, and then enters the city in a text box, the name entered in the
> city is validated against the values in the table (WHERE city = XXX).
> Then, there is another readonly field that I need populated with the
> rates value associated with that city. If someone could show me an
> example of what I'm trying to do it would be greatly appreciated.
>
> Thanks in advance,
> KP
>
Kyle Peterson [ Mo, 20 März 2006 04:40 ] [ ID #1237692 ]

Re: Textbox value validation using database table

Were you able to solve your problem? If not i have a few tutorials i
came across
nvanhaaster [ Mo, 20 März 2006 08:41 ] [ ID #1237693 ]
Webserver » microsoft.public.inetserver.asp.db » Textbox value validation using database table

Vorheriges Thema: inserting into a database using asp.net
Nächstes Thema: IDIOT