Solved

Can you please provide me equivalent VBScript for this JavaScript ?

Posted on 2007-12-02
6
927 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

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

Question has a verified solution.

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

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…
Suggested Courses

630 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