Click to See Complete Forum and Search --> : VBScript help needed
Euthorus
07-20-2005, 05:35 PM
I have a unique challenge of trying to automate a process of users clicking on the same HTML form elements over and over. The forms are fairly simple however we do have some javascript that for exmplae select ALL checkboxes when a button is pressed.
One such page is making me want to pull my heair out :eek:
I want to simulate a click on Select All option in the list and then submit the form (see the screenshot)
The javascript function that is built-into the page is fairly simple and loops through available checkboxes selecting them all. I have thus far tried everything from WSH to javascript calls to execute that function from within the vbscript all to no avail.
Anyone have any ideas ? Thank you in advance :t
ScaryBinary
07-20-2005, 09:28 PM
I'm confused.
Are you talking about client-side VBScript, or server-side VBScript (e.g., ASP)? Javascript is client-side only, so if your're trying to run a javascript from an ASP page, I think you're in trouble.
If you have a web page that has two different <script> tags, both to be executed by the client, then maybe we can figure something out. I'll experiment a bit and see what happens.
At any rate, I highly recommend staying away from VBScript for client-side scripting. It's only really supported by Internet Explorer. Javascript is pretty standard now-a-days, and will work much better with a wider variety of browsers - which is important now that Firefox, Opera, etc. are so popular.
ScaryBinary
07-20-2005, 09:37 PM
Here's an example of calling a client-side VBScript from a client-side Javascript:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script language="VBScript">
<!--
Sub vbMessage()
' Here's a client-side VBScript. It will display a message box.
MsgBox "This message box was called from a VBScript function."
End Sub
//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--
function jsMessage()
{
/* This is client-side javascript. It will display a message box. */
alert('This message box was called from a Javascript function.');
/* Now see if we can call a VBScript function... */
vbMessage() ;
}
//-->
</script>
</head>
<body>
<form name="frmTest">
<input type="button" value="Test Two Scripts!" onclick="javascript:jsMessage();" />
</form>
</body>
</html>
Note that this will only work in IE. The VB portion will not get executed in, say, Firefox.
ScaryBinary
07-20-2005, 09:46 PM
Woops, my example there was backwards from what you wanted. The following HTML page will do both: call a VBScript from a Javascript, and call a Javascript from a VBScript.
Again, I would not recommend doing this. It may tear the very fabric of the space-time continuum.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script language="VBScript">
<!--
Sub vbMessage_1()
' Here's a client-side VBScript. It will display a message box.
MsgBox "This message box was called from a VBScript function. " & _
"Now we'll call a Javascript function from this VBScript."
jsMessage_2
End Sub
Sub vbMessage_2()
' Here's a client-side VBScript. It will display a message box.
MsgBox "This message box was called from a VBScript function, that was called from a Javascript function."
End Sub
//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--
function jsMessage_1()
{
/* This is client-side javascript. It will display a message box. */
alert("This message box was called from a Javascript function. " +
"Now we'll call a VBScript function from this Javascript function.");
/* Now see if we can call a VBScript function... */
vbMessage_2() ;
}
function jsMessage_2()
{
alert("This message box was called from a Javascript function, that was called from a VBScript function.") ;
}
//-->
</script>
</head>
<body>
<form name="frmTest">
<input type="button" value="Call VBScript from Javascript!" onclick="javascript:jsMessage_1();" />
<input type="button" value="Call Javascript from VBScript!" onclick="vbMessage_1()" />
</form>
</body>
</html>
Euthorus
07-25-2005, 01:51 PM
This certainly gives me more ideas - thank you once again for your help ! :x
SysOpt.com
Copyright Internet.com Inc. All Rights Reserved.