Click to See Complete Forum and Search --> : Can I call a VBScript Function from a JavaScript function?


kateyez44
11-25-2002, 10:21 AM
Hi. I was wondering how I could call a VBScript function from within a JavaScript function. When my form is submitted, a JavaScript function to validate the form is called. The Validate function calls another JavaScript function that returns true or false. I would like to conditionally call a VBScript function from the JavaScript function depending on whether true or false is returned. The VBScript function calls a COM object to save changes to the form. Here is what I have tried:


<SCRIPT TYPE="text/vbscript" LANGUAGE="VBScript">
<!--
Function SaveChanges()
Dim tmpMonth, tmpDay, tmpYear, tmpDate

intFrmID = 1
Set oDBCnObj = Server.CreateObject("AASForm525D3DB.DBConnect")
oDBCnObj.ConnectToDB

Set oDBFunctions = Server.CreateObject("AASForm525D3DB.Form525D3DB")
oDBFunctions.SetActiveConnection oDBCnObj.GetCurrentConnection
Set rsClaimant = oDBFunctions.LoadClaimantForm(CInt(intFrmID))

End Function
-->
</SCRIPT>

</SCRIPT>

<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
<!--
function ValidateClaimantDrugForm()
{var objForm = document.frmClaimantDrug;
var blSaved;

with (objForm) {
var strEmpBegin = lstEmpBeginM.value + "/" + txtEmpBeginD.value + "/" + txtEmpBeginY.value;
.
.
.
.
if (doValidation())
{
blSaved = Function('return SaveChanges()');

if(blSaved == true)
{
return false;
}
else if(blSaved == false)
{
return true;
}
}
else
{
return false;
}
}//with
} //validateClaimantDrugForm


This is not working at all. How in the world do I go about doing this? I appreciate any help or advice.

Taersious
12-18-2002, 01:09 PM
Yes. The way I have done this is to use a form with hidden fields and programmatically click the submit button to an ASP page. If you have any variables you are wanting to save/store in a db or file, you must load that information into hidden fields (that is what I have done).

Let me know if you need further clarification.

>DREW<