Click to See Complete Forum and Search --> : Converting JSP variable to ASP?


Jantsu
May 6th, 2001, 05:16 PM
Can anyone tell me how to convert a javascript variable value to ASP variable?

In JSP I have:

<script language="JavaScript">
function sublist(inform, selecteditem) {
.
.
.
var number = document.subad.number.value

'And now I need to do some database stuff and the "number" value in ASP.
.
.
.
<%
numberASP = ???
Set R = objDB.Execute("SELECT * FROM db WHERE number = " & numberASP)
.
.
.
%>
.
.
.
}
</script>

Or is there an other way to do that database query? Can I use JSP variable in ASP code? How?

Hope you get the point :).

Cakkie
May 7th, 2001, 02:14 AM
You cannot use that variable in ASP. This is because ASP runs at the server, and the script runs at the client. You will have to store the data in a form element (this can be hidden) and submit the page to an asp page. Then, the value can be retrieved with the request.form or the request.querystring properties.

Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook

Jantsu
May 7th, 2001, 05:24 AM
The problem is that the page is not reloaded. And because of that I can't use the request term.

The thing I'm doing there is a "dependant listbox". The effect works fine, but I wanted to fine tune it to make it look prettier.

So if I can't do it that way I have to figure out some other way... ;)

sudhi_75
May 7th, 2001, 07:37 AM
You can make it look prettier by having an submit button which is hidden and calling the click event of that button using javascript in the onchange event of the list box. if the listbox is dependent on some other value, put that value in the textbox and make it hidden.

Jantsu
May 7th, 2001, 08:14 AM
Thanx!

I try that...

chris75
May 9th, 2001, 10:26 AM
Firstly, if you can pass the javascript value successfully in the submission of the form (as mentioned in another reply you've had), you will then need to use this code to 'receive' it in the ASP code :

numberASP = request.form("number")

(this assumes you are assigning the value to the form element called "number" in javascript).

Just a final note : You may be confusing "JSP" with "Javascript" - just in case you are, here's the difference :

Javascript is the script that can be added into HTML to give it extra capabilities, and is run "live" at the users browser.

JSP is a type of web page that like ASP runs at the server rather than the browser, and usually interacts with a server-based database. JSP is to Java what ASP is to VB.

I hope that I've answered your question!
chris