Friday, April 11, 2008

Passing values between Javascript and Vbscript

Very few applications are using Vbscript, but lot of old code exsists that use Vbscript. So its not very difficult to run into a situation where values have to be passed from one to the other. First i was thinking of using a hidden text box to pass values between the two... but its much easier. You can call variables from both, meaning variables are not specific to the scripting langauge as both are client side scripting langauges.

See the following code:

<html>
<body>

<script>
jvalue=confirm('Pass a value to Javascript');
</script>

<script type="text/vbscript">
document.write(lcase(jvalue))
<!--javascript variable used in Vbscript function -->

vvalue=ucase("vbscript here")
</script>

<script>

alert(vvalue)
</script>
<!--Vbscript variable used in Javascript function -->

<input type='hidden' name='passval'>

<!--no need of hidden text box-->

</body>
</html>


This example shows how one can use variables from javascript in vbscript and also vice-versa.
The situation is very different when values are to be passed between a client side script and a server side script.

4 comments:

Unknown said...

i have a problem with my coding . Passing value from javacript to vbscript. Need ur help urgently. if u can leave ur email. i'll email the coding to you.

Anonymous said...

hola,

not positive anyone is interested in wanting to own an [url=http://free--iphone4s.com]i-phone[/url] 4 s or not, but here is a site I've found that offers contests giving em away. it's simple and painless to enter & FREE!!


gl

Anonymous said...

I'm a beginner, so this is a bit confusing for me.

If you hardcode a value into a variable, doesn't the variable become a constant? So, in actuality, are you not passing constants rather than variables?

'Constant' may be the wrong terminology here but, in my noobish mind, once a variable has a hardcoded value, it is no longer a variable.

Author said...

Nothing is hardcoded, as the value can be anything that is assigned to the variable.