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

Is there someway of passing values from vb script to javascript 2

Status
Not open for further replies.

bryant89

Programmer
Nov 23, 2000
150
CA
If anyone knows how this can be done or anyway of using values (variables from vb script) in a javascript function please help
 
Yes, you can make that work, however there are potential problems and perfomance issues with running both scripting engines in the same page. There are MSDN articles about that issue that you might want to read.

Without knowing specifically what you want to do here is a generic example:

<%@ language=javascript %>
<SCRIPT LANGUAGE=vbscript RUNAT=Server>
DIM g_name

function vb_getName()
if &quot;&quot; = g_name then g_name = &quot;VB Variable&quot;
vb_getName = g_name
end function

</SCRIPT>

<BODY>
<% var sVbName = vb_getName(); %>
VB Variable from javascript: <%=sVbName%>


Hope this helps
-pete
 
Actually there is a simple method I used in various forms on my site. All you have to do is create a hidden text field in a form. Then in your initial asp script at the top of the page, get whatever value you need from your recordset and place this value in the hidden field with standard response.write or <% = rs('Columnname') %>.

In your Javascript function, just refer to the document.formname.fieldname.value.

Hope that is what you are looking for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top