Reputation: 77
Hi am trying to get the textbox value of one asp page to other asp page and set the value here is VBScript which it does
If(disableListHeaderPR()) Then
bEnablePRField = false
Else
bEnablePRField = true
End If
Here disableListHeaderPR()
is JS function. I am getting error saying Variable is undefined: 'disableListHeaderPR'
Here is the JS function code
function disableListHeaderPR()
{
if(dateDifference(document.getElementById("txtCommDte").value, "05/04/2012") < 0 )
{
return false;
}
else
{
return true;
}
}
Upvotes: 0
Views: 6421
Reputation: 25081
My solution would be to set your variable in the VBScript server-side and then flush the result out to the page in a different JavaScript function that calls your other JavaScript function. Sample (untested) as follows:
<%
Dim bEnablePRField
bEnablePRField = Request.Form("checkboxEnablePRField") <> ""
%>
<script type="text/javascript">
function EnablePRField() {
if (<%=bEnablePRField%> === 'False') {
disableListHeaderPR();
}
}
function disableListHeaderPR() {
if (dateDifference(document.getElementById("txtCommDte").value, "05/04/2012") < 0 ) {
return false;
} else {
return true;
}
}
</script>
Something very similar to that should work for you.
I feel I should point out that, for Classic ASP, the VBScript is only processed server-side so this should work in any browser that supports JavaScript. Before I switched to .Net, I used to pull this trick a lot, and it worked fine in Firefox, as well as IE.
Should you wish instead to use the results of your JavaScript function in your VBScript function, simply store the results of the JavaScript function in a hidden field (e.g., <input id="myResults" name="myResults" type="hidden" />
) and then access the value in VBScript (e.g., Request.Form("myResults"
).
You can also use the hidden field if you are mixing VBScript and JavaScript on the client-side. Just change the way you access the hidden field in VBScript (e.g., document.form("myForm").myResults.value
).
Finally, I cannot agree more with techfoobar. If you are mixing VBScript and JavaScript on the client-side, then the only browser it will work in is IE and I would also strongly recommend switching over entirely to JavaScript.
Hope this helps,
Pete
Upvotes: 0
Reputation: 66663
This page has info on calling vbs from js and vice-versa.
http://www.webdeveloper.com/forum/archive/index.php/t-49920.html
But do keep in mind that as long as you are using VBScript, your app won't run as expected in any browser other than IE.
Upvotes: 2