473,395 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Run SQL on form button and output result on page

Hi,

I have an asp page with a form.
A user enters a serial number in a text box.

I want to add a button next to the text box such as 'Check Serial' to
run some SQL in the background to see if that serial exists in the
table, and then output 'Serial found' or 'Serial Not Found' next to
the text box, so the user can decide whether to continue with the
form.
Appreciate your help.

Thanks
David

Apr 13 '07 #1
7 2815

"David" <da*********@scene-double.co.ukwrote in message
news:11**********************@y5g2000hsa.googlegro ups.com...
Hi,

I have an asp page with a form.
A user enters a serial number in a text box.

I want to add a button next to the text box such as 'Check Serial' to
run some SQL in the background to see if that serial exists in the
table, and then output 'Serial found' or 'Serial Not Found' next to
the text box, so the user can decide whether to continue with the
form.
Have a look at the xmlhttpobject in javascript: www.w3schools.com/ajax

--
Mike Brind
Apr 14 '07 #2
Using VB and ADO I have stored proc that checks for a value and give
the return value. And kicks off the event onBlur

<SCRIPT LANGUAGE="vbscript">
Public Sub getID(id)
Dim cn: Set cn = CreateObject("ADODB.Connection")
Dim cmd: Set cmd = CreateObject("ADODB.Command")
Dim rs: Set rs = CreateObject("ADODB.Recordset")

'cn.Open "db.udl"
cn.Open "Provider=SQLOLEDB.1;Password=[Password];Persist
Security Info=True;User ID=[UserID];Initial Catalog=[Database];Data
Source=[Server Name]"
cn.CursorLocation = 3
cmd.ActiveConnection = cn
cmd.CommandType = 4

cmd.CommandText = "[dbo].[View:GetID]"
cmd.Parameters.Append (cmd.CreateParameter ("@ID",3, 1, 0,
Null ))
cmd.Parameters.Item("@ID").Value = id
rs.Open cmd

If rs.RecordCount = 0 Then
MsgBox id & " is not a valid ID.", vbOkOnly, "Error"
document.all("WorkoutID").Value = ""
document.all("WorkoutName").innerHTML = ""
Else
document.all("WorkoutID").Value = id
document.all("WorkoutName").innerHTML =
rs.Fields.Item("Topic")

End if
End Sub
</SCRIPT>
<input name="WorkoutID" size="5" type="text"
onblur="vbscript:getId(WorkoutID.value)">
Apr 20 '07 #3
xx******@gmail.com wrote:
Using VB and ADO I have stored proc that checks for a value and give
the return value. And kicks off the event onBlur

<SCRIPT LANGUAGE="vbscript">
Public Sub getID(id)
Dim cn: Set cn = CreateObject("ADODB.Connection")
Dim cmd: Set cmd = CreateObject("ADODB.Command")
Dim rs: Set rs = CreateObject("ADODB.Recordset")

'cn.Open "db.udl"
cn.Open "Provider=SQLOLEDB.1;Password=[Password];Persist
Security Info=True;User ID=[UserID];Initial Catalog=[Database];Data
Source=[Server Name]"
Dangerous! You do realize this is all visible to the user simply via
View|Source ??

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Apr 20 '07 #4
On Apr 20, 3:48 pm, "Bob Barrows [MVP]" <reb01...@NOyahoo.SPAMcom>
wrote:
xxsho...@gmail.com wrote:
Using VB and ADO I have stored proc that checks for a value and give
the return value. And kicks off the event onBlur
<SCRIPT LANGUAGE="vbscript">
Public Sub getID(id)
Dim cn: Set cn = CreateObject("ADODB.Connection")
Dim cmd: Set cmd = CreateObject("ADODB.Command")
Dim rs: Set rs = CreateObject("ADODB.Recordset")
'cn.Open "db.udl"
cn.Open "Provider=SQLOLEDB.1;Password=[Password];Persist
Security Info=True;User ID=[UserID];Initial Catalog=[Database];Data
Source=[Server Name]"

Dangerous! You do realize this is all visible to the user simply via
View|Source ??

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
not if you put it inside of server side tags

May 4 '07 #5
On Apr 20, 3:48 pm, "Bob Barrows [MVP]" <reb01...@NOyahoo.SPAMcom>
wrote:
xxsho...@gmail.com wrote:
Using VB and ADO I have stored proc that checks for a value and give
the return value. And kicks off the event onBlur
<SCRIPT LANGUAGE="vbscript">
Public Sub getID(id)
Dim cn: Set cn = CreateObject("ADODB.Connection")
Dim cmd: Set cmd = CreateObject("ADODB.Command")
Dim rs: Set rs = CreateObject("ADODB.Recordset")
'cn.Open "db.udl"
cn.Open "Provider=SQLOLEDB.1;Password=[Password];Persist
Security Info=True;User ID=[UserID];Initial Catalog=[Database];Data
Source=[Server Name]"

Dangerous! You do realize this is all visible to the user simply via
View|Source ??

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup

Also can just do async calls with it.

May 4 '07 #6
xx******@gmail.com wrote:
On Apr 20, 3:48 pm, "Bob Barrows [MVP]" <reb01...@NOyahoo.SPAMcom>
wrote:
>xxsho...@gmail.com wrote:
>>Using VB and ADO I have stored proc that checks for a value and give
the return value. And kicks off the event onBlur
>><SCRIPT LANGUAGE="vbscript">
<snip>
>Dangerous! You do realize this is all visible to the user simply via
View|Source ??
<snip>
not if you put it inside of server side tags
But your example shows it in a client-side script element.
At least now you are aware of the desirability to do this in server-side
code,
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
May 4 '07 #7
xx******@gmail.com wrote:
>
Also can just do async calls with it.
And why is this relevant? If it is in client-side script, the user can see
it, whether async calls are done with it or not.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
May 4 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Michael Brennan-White | last post by:
If I submit my for using a get action the resulting page loads . If I use a post action I get an error page saying "The page cannot be found". I am calling the originating page!!! This happens...
10
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is...
6
by: CJM | last post by:
Can somebody clarify if/how/when a simple form is submitted when the <Enter> key is pressed? As I understood it, if you have a form with a single submit button, if enter is pressed, the form...
5
by: rjames.clarke | last post by:
I have the following. $result=mysql_query($sql); $nrows=mysql_num_rows($result); for ($i=0;$i<$nrows;$i++) { $row_array=mysql_fetch_row($result); echo "<form name='testform'...
3
by: Adam Benson | last post by:
Hi, I have a really simple web page with c# code behind it. It displays news headlines with related text. Click on the headline and you get the text that goes with it. I need to implement a...
35
by: Aaron Gray | last post by:
Hi, I have some code I just cannot seem to get to work properly on FireFox. It is probably something simple. On FireFox the following code does not seem to terminate in the browser, but it...
1
by: rn5a | last post by:
A custom server control has a Button. Namespace Confirm Public Class ShowConfirm : Inherits Button Private strConfirmMsg As String Public Property ConfirmMessage() As String Get...
13
by: David W. Fenton | last post by:
I've been struggling the last two days with something I thought was very easy, which is to open a web page with a form on it and populate the form with data passed in a query string (either POST or...
0
by: JRough | last post by:
Hi, I have a page with a form that is included into a php page. It has some php variables which are headers based on the user choices. In the form I will send some mysql data columns but right...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.