Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I call an MS-SQL stored procedure from Javascript?

Status
Not open for further replies.

Invicta

Programmer
May 30, 2000
28
0
0
GB
As a learning exercise I'm writing a small application but I've hit a small problem and I'd like some help.

I have a form. On the form is a selection box. When the user selects one of the options the cursor moves onto the next input box. The bit that's missing is the bit that pre-populates this input box after the selection was made but before the cursor hits the input box.

I'd like to use "onblur" (when the user leaves the selection box) to call an MS-SQL stored procedure with the selected option as a parameter and pre-populate the input box with a returned value.

For information, I already have a connection (objConn) and I access stored procedures like this elsewhere in my application:

set cmd=Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = objConn
cmd.CommandType = adCmdText
set rsDeviceNames = Server.CreateObject("ADODB.Recordset")
cmd.CommandText = "GetDeviceList '" & session("SiteID") & "'"
set rsDeviceNames = cmd.Execute

I then harvest the data from the returned recordset as required.
[sig][/sig]
 
You're trying to mix server-side and client-side processing. You can't do what you want without another trip to the server.

In other words, after the selection is made from the selection box, you'll need to go back to the server, get the data from the database, and create another page. [sig]<p>nick bulka<br><a href=mailto: > </a><br><a href= </a><br>Get your technical books at Bulka's Books<br>
[/sig]
 
Thanks Nick.

I could come back to the same page but with request(&quot;varname&quot;) populated, maybe?

I was hoping for a solution where &quot;onblur&quot; calls a javascript function that itself invokes an MS-SQL stored proc and uses the returned value to pre-poulate the input box using something like this:

<script>
function FillInputBox(parameter)
{
call to the MS-SQL SP with parameter
document.FormName.InputBoxName.value = SPReturnedValue
}
</script>

[sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top