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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing variabel from javascript to vbscript server-side

Status
Not open for further replies.

pet41

Programmer
Sep 13, 2005
16
NO
Hi

Can someone help me. Here is my script (some of it)

<script language="vbscript" runat="server">

dim itemtxt

sub gendata(bid)

set OBJdbConnection = Server.CreateObject("ADODB.Connection")
OBJdbConnection.ConnectionString = "driver={SQL Server};XXXXXXXXXXXXX;uid=XXXXXXX;pwd=XXXXX;database=softinn_reg"
OBJdbConnection.Open
set RsCustomerList = Server.CreateObject("ADODB.Recordset")
RsCustomerList.ActiveConnection = OBJdbConnection
RsCustomerList.CursorType = adOpenKeyset
RsCustomerList.LockType = 3
RsCustomerList.source = "select ItemDesc from eCatalog where Catalognr='" & bid & "' and USID='bcQ4-Az9k'"
RsCustomerList.open
itemtxt = RsCustomerList("ItemDesc")
RsCustomerList.close
end sub

</script>


<script language="javascript">

function lookupbid(bid){

<%dim bid
bid = %> + bid

<%gendata(bid)%>
return('<%= itemtxt %>');
}
</script>


The probelm is that the java-variabel bid (in red) is empty when the page are loading. Can I do this in a different way?

regards
Rune
 
Are you confusing server-side and client-side? Once the server has delivered the HTML, there is no way to interact with the server-side variables etc. If you want to pass the contents of a variable from the server-side to the client-side, then you would do it like this:
Code:
function wibble() {
  var testVariable = '<%=variable_server_side%>';
}
If the contents of the variable (server-side) was "hello" then the end result (when you select "View Source" in your browser) will be:
Code:
function wibble () {
  var testVariable = 'hello';
}
With this knowledge you may find you can solve your problem. If not, then make sure you paste the rendered HTML source for any client-side code you need help with.

Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]
 
Thanks
I think I slowly understand. So what you mean is that variabels on server-side after the pages are load is gone.

If I put the variabels in an arry like this:

do while not RsCustomerList.eof
arritem(i) = RsCustomerList("ItemDesc")
arrcat(i) = RsCustomerList("Catalognr")
RsCustomerList.movenext
i = i + 1
loop

there are now way to get them back. Is this right.
 
An array is a variable... and as you said (correctly) - after page load they are gone.

You *could* store the infomation in a session variable server-side... that will be accessible server-side for as long as their session is active (usually the duration they have their browser window open for). For more information on doing this in ASP you should direct a question at the appropriate forum333.

Session variables are also available in other environments including php and jsp - just in case you ever decide to switch [smile]

Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top