sarge
07-10-2006, 03:05 PM
Hi-
Because of the limitations of Firefox, I need to convert some VBScripts to Javascripts.
I took a simple example, and put it through a converter, and.. it fell over.
Going through Javascript tutorials, I found that smooth brackets were needed after function, and when I put these in, it moved to the next stage - the curly brackets nightmare.
I've tried every combination of curly brackets that I can think of, but the syntax checker is never satisfied.
I'm frustrated, confused, despairing & angry with Javascript... and life shouldn't be like that. :-(
Could a Javascript guru please cast a quick eye over this?
Thanks,
Brian
====Here's the original VBScript======
<SCRIPT language="VBSCRIPT">
sub document_onclick
Select Case window.event.srcElement.id
Case "terms"
if FrontPage_Form2.terms.value = "OFF" then
FrontPage_Form2.terms.value = "ON"
MSG1.Style.Visibility = "Hidden"
MSG2.Style.Visibility = "Visible"
generate.Style.Visibility = "Visible"
else
FrontPage_Form2.terms.value = "OFF"
MSG1.Style.Visibility = "Visible"
MSG2.Style.Visibility = "Hidden"
generate.Style.Visibility = "Hidden"
end if
Case else
exit sub
End Select
end sub
</SCRIPT>
====Here's the attempted Javascript equivalent...=======
<SCRIPT language="JavaScript">
document.onclick = function(){
switch(window.event.srcElement.id){
Case "terms";
if(FrontPage_Form2.terms.value == "OFF"){
FrontPage_Form2.terms.value = "ON";
MSG1.Style.Visibility = "Hidden";
MSG2.Style.Visibility = "Visible";
generate.Style.Visibility = "Visible";
}else{
FrontPage_Form2.terms.value = "OFF";
MSG1.Style.Visibility = "Visible";
MSG2.Style.Visibility = "Hidden";
generate.Style.Visibility = "Hidden" ;
}
case }else{: {
exit sub;
break;
}
}
}
</SCRIPT>
Because of the limitations of Firefox, I need to convert some VBScripts to Javascripts.
I took a simple example, and put it through a converter, and.. it fell over.
Going through Javascript tutorials, I found that smooth brackets were needed after function, and when I put these in, it moved to the next stage - the curly brackets nightmare.
I've tried every combination of curly brackets that I can think of, but the syntax checker is never satisfied.
I'm frustrated, confused, despairing & angry with Javascript... and life shouldn't be like that. :-(
Could a Javascript guru please cast a quick eye over this?
Thanks,
Brian
====Here's the original VBScript======
<SCRIPT language="VBSCRIPT">
sub document_onclick
Select Case window.event.srcElement.id
Case "terms"
if FrontPage_Form2.terms.value = "OFF" then
FrontPage_Form2.terms.value = "ON"
MSG1.Style.Visibility = "Hidden"
MSG2.Style.Visibility = "Visible"
generate.Style.Visibility = "Visible"
else
FrontPage_Form2.terms.value = "OFF"
MSG1.Style.Visibility = "Visible"
MSG2.Style.Visibility = "Hidden"
generate.Style.Visibility = "Hidden"
end if
Case else
exit sub
End Select
end sub
</SCRIPT>
====Here's the attempted Javascript equivalent...=======
<SCRIPT language="JavaScript">
document.onclick = function(){
switch(window.event.srcElement.id){
Case "terms";
if(FrontPage_Form2.terms.value == "OFF"){
FrontPage_Form2.terms.value = "ON";
MSG1.Style.Visibility = "Hidden";
MSG2.Style.Visibility = "Visible";
generate.Style.Visibility = "Visible";
}else{
FrontPage_Form2.terms.value = "OFF";
MSG1.Style.Visibility = "Visible";
MSG2.Style.Visibility = "Hidden";
generate.Style.Visibility = "Hidden" ;
}
case }else{: {
exit sub;
break;
}
}
}
</SCRIPT>