VBscript 2 Jscript ??

RussianSpy
11-16-2001, 02:34 PM
is there VBscript 2 Jscript converter?
i don't know Jscript but Netscape and Opera don't understand VBscript :(

Derek Stone
11-16-2001, 06:22 PM
There isn't a program that does it as far as I know, but I think I, and many of us, might be off some use to you.
Try posting the code you want converted.

Good Luck
-cl

RussianSpy
11-16-2001, 07:19 PM
that'd be cool, i wouldn't dare ask for large code, but i've got a small one u can help me w/ :-)


basically there's a form on a page w/ 4 input boxes, a button and another input box to show result:

<FORM id="CalcForm" onsubmit="CalcTick(); return false;" language="jscript">
Current Hour: <INPUT TYPE="Text" NAME="CurHR" SIZE="5">
Current Tick: <INPUT TYPE="Text" NAME="CurTick" SIZE="5">
Hour Recieved: <INPUT TYPE="Text" NAME="anHRRecieved" SIZE="5">
ETA: <INPUT TYPE="Text" NAME="anETA" SIZE="5">

<input name="Submit" TYPE="Submit" VALUE="Calculate Tick >>">
<INPUT TYPE="Text" NAME="FinalTick" SIZE="5">
</FORM>


and this is that sub thats called on button click:

Sub CalcTick()
Dim TheForm
Set TheForm = Document.forms("CalcForm")

If CInt(TheForm.anHRRecieved.Value) > CInt(TheForm.CurHR.Value) then TheForm.CurHR.Value = 24 + CInt(TheForm.CurHR.Value) : TheForm.CurHR.Value = CStr(TheForm.CurHR.Value)
TheForm.FinalTick.Value = CInt(TheForm.CurTick.Value) + ((CInt(TheForm.anHRRecieved.Value) + CInt(TheForm.anETA.Value)) - CInt(TheForm.CurHR.Value))
End Sub


TIA!

Ad1
11-19-2001, 02:10 AM
replace CInt() with parseInt()

and replace Set TheForm = Document.forms("CalcForm") with TheForm=document.getElementById("CalcForm");

the main things to remember in javascript is to end your command lines with ; and that it is case sensitive, not like good old VB

RussianSpy
11-19-2001, 09:23 AM
i've took that Sub out of VBScript section and changed it to this:

<pre>
&lt;SCRIPT LANGUAGE="JScript"&gt;
&lt;!--

function CalcTick()
{
var TheForm;
TheForm = document.getElementById("CalcForm");

if (parseInt(TheForm.anHRRecieved.Value) &gt; parseInt(TheForm.CurHR.Value))
{
TheForm.CurHR.Value = 24 + parseInt(TheForm.CurHR.Value);
TheForm.CurHR.Value = parseStr(TheForm.CurHR.Value);
}

TheForm.FinalTick.Value = parseInt(TheForm.CurTick.Value) + ((parseInt(TheForm.anHRRecieved.Value) + parseInt(TheForm.anETA.Value)) - parseInt(TheForm.CurHR.Value));
}

--&gt;
&lt;/SCRIPT&gt;
</pre>.

and it doesn't work (IE doesn't show any errors too)
i don't know anything anout JS

Ad1
11-19-2001, 09:59 AM
jscript is a fussy [censored] ,rewrite .Value as .value

Ad1
11-19-2001, 10:11 AM
BTW I don' t think parseStr is valid syntax and it will probably give you an error

RussianSpy
11-19-2001, 10:51 AM
yep, ur right, i got it. had to find some JS tutorial :))
Thnx alot for all the help!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum