Solved

Can you please provide me equivalent VBScript for this JavaScript ?

Posted on 2007-12-02
6
922 Views
Last Modified: 2008-02-01
<html>

      <head>
            
            <script language="javascript">
            
            function FuncKeyboard(e)
            {
                  var key;

                  if (window.event)
                  {
                        key = window.event.keyCode;
                  }
                  else
                  {
                        key = e.keyCode;
                  }

                  if (key == 13)
                  {
                        document.forms[0].submit();
                  }
            }

            window.onload = function()
            {
                  document.forms[0].elements["text2"].onkeydown = FuncKeyboard;
            }

            </script>

      </head>
      
      <body>

            <form action="Sample.asp" method="post">

                  <input type="text" name="text1" id="text1" value="">

                  <input type="text" name="text2" id="text2" value="">
                  
                  <input type="submit" name="submit1" id="submit1" value="Submit">

            </form>

      </body>

</html>

Can you please provide me equivalent VBScript for this JAVAScript ?

Thanks
0
Comment
Question by:kishore_peddi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 29

Assisted Solution

by:Göran Andersson
Göran Andersson earned 200 total points
ID: 20392414
Why would you want it in VBScript, when Javascript works in any browser, and VBScript only in Internet Explorer?

Anyhow, this should work:

<script language="VBScript">
           
Function FuncKeyboard(e)
      If window.event.keyCode = 13
            document.forms(0).submit()
      End If
End Function

Function Init()
      document.forms(0).elements("text2").onkeydown = FuncKeyboard;
End Function

window.onload = Init

</script>
0
 
LVL 25

Expert Comment

by:imitchie
ID: 20392453
<script language="javascript">
function FuncKeyboard(e)
  key = window.event.keyCode
  if (key = 13) then
    document.forms[0].submit()
  end if
end function
function initme()
  document.forms[0].elements["text2"].onkeydown = FuncKeyboard;
end function

Set Window.Onload=GetRef("initme")
</script>
0
 
LVL 25

Expert Comment

by:imitchie
ID: 20392463
correction to this function

function initme()
  Set document.forms[0].elements["text2"].onkeydown = GetRef("FuncKeyboard")
end function

if it complains about the "Set" statements, remove the Set keyword
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:kishore_peddi
ID: 20392714
Here is the code...still i have some bugs:

<html>

      <head>
            
            <script language="vbscript">
            
            Sub MethodKeyboard(e)

                  If (window.event.keyCode = 13) Then
                        document.forms(0).submit()
                  End If

            End Sub

            Sub Init()

                  document.forms(0).elements("text2").onkeydown = GetRef(MethodKeyboard)
            
            End Sub

            Set window.onload = GetRef(Init)

            </script>

      </head>
      
      <body>

            <form action="Sample.asp" method="post">

                  <input type="text" name="text1" id="text1" value="">

                  <input type="text" name="text2" id="text2" value="">
                  
                  <input type="submit" name="submit1" id="submit1" value="Submit">

            </form>

      </body>

</html>

Can you please check ?

Thanks
0
 
LVL 25

Accepted Solution

by:
imitchie earned 300 total points
ID: 20392734
GetRef requires the parameter to be a String. Make sure you quote them, like

 Set window.onload = GetRef("Init")
0
 

Author Comment

by:kishore_peddi
ID: 20392762
imitchie:

Great...works fine.

Thanks
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question