19185

Pass and Return value from Javascript to VBScript, Vice Versa in ASP

Question:

My code is below, I would like to make this work because my existing webpage that I am working at mostly uses VBScript. I am using ajax to query values to SQL. I would hate to change most of the code so I was just wondering if it would be possible to put back a return value from javascript to vbscript like my code below.

<SCRIPT LANGUAGE="VBSCRIPT"> Sub check() Dim a Dim b a = 1 b = retValue a MsgBox b End Sub <SCRIPT LANGUAGE="JavaScript"> function retValue(a){ return a + 1; } </SCRIPT>

Answer1:

It is possible.

You have 2 issues in your script.

<ul><li>Your Script tag for vbscript does not have </script></li> <li>retValue is a function. you need to pass the arguments with in ( )</li> </ul>

I tried to call check & it shows the msgbox with the text 2

<SCRIPT LANGUAGE="VBSCRIPT"> Sub check() Dim a Dim b a = 1 b = retValue(a) MsgBox b End Sub </script> <SCRIPT LANGUAGE="JavaScript"> function retValue(a){ return a + 1; } </SCRIPT>

Recommend

  • orm.xml named query with input parameter
  • What should I use to create a Windows GUI?
  • vbscript syntax in asp classic
  • Need help converting DataTable to XML VB.NET
  • CRLF in VBScript
  • Why does regasm /regfile seem incomplete?
  • Access VBScript variable within Javascript inside of an HTA
  • What is this strange character in chrome's resource css viewer?
  • How to repeat sections of a SQL query across UNIONs? (DRY in SQL)
  • in batch how do i use taskkill properly
  • NUnit 3.0 TestCase const custom object arguments
  • What does 'Language neutral' mean with regard to MAKELANGID?
  • jQuery ready not fired after rails link_to is clicked
  • Android activity accessing service's static reference before the service is ready
  • Switching to Release Build causes runtime error in Web Reference
  • Java: can you cast Class into a specific interface?
  • DomPDF {PAGE_NUM} not on first page
  • Javascript simulate pressing enter in input box
  • HTML download movie download link
  • AES padding and writing the ciphertext to a disk file
  • Updating server-side rendering client-side
  • How to extract text from Word files using C#?
  • Importing jscolor library in angular 2
  • Calling of Constructors in a Java
  • Traverse Array and Display in markup
  • Transpose CSV data with awk (pivot transformation)
  • A cron job substitute?
  • Python: how to group similar lists together in a list of lists?
  • Why can't I rebase on to an ancestor of source changesets if on a different branch?
  • How to set the response of a form post action to a iframe source?
  • Understanding cpu registers
  • Setting background image for body element in xhtml (for different monitors and resolutions)
  • Django query for large number of relationships
  • costura.fody for a dll that references another dll
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • Observable and ngFor in Angular 2
  • How can I use `wmic` in a Windows PE script?
  • UserPrincipal.Current returns apppool on IIS
  • java string with new operator and a literal
  • How to push additional view controllers onto NavigationController but keep the TabBar?