Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB Script to Javascript 1

Status
Not open for further replies.

timb94

Programmer
Apr 20, 2004
58
US
New to Javascript.

I have the following VB Script that I think I need to convert to Javascript. The VB Script was working prior to IE7 and all of a sudden no longer works. I read somewhere that some VB Script does not work in IE7.

Here is the VB Script:
Code:
<script language="vbscript" type="text/vbscript">
<!--
Sub OnAddHmst
	Dim strResponse strApp strURL strPID ValApp
	strResponse=msgbox("You are about to add a new application with the same Parcel ID that already exist on the file.  If you click 'YES' the existing application will be marked as inactive and you will be directed to the AssessPro Validation form.  Do you want to continue", 36, "Create New Record")
	If strResponse = 6 Then
		strApp = document.HMSTEDITADDRESS.ApplicationNumber.value
		strPID = document.HMSTEDITADDRESS.pid.value
		window.navigate("hmstvalidate.asp?AppNumber=" & strApp & "" & "&parent=edithmst" &"" & "&PID=" & strPID & "")
	End If

end Sub
-->
</script>
This is executed from a button click:
Code:
Response.Write "<input CLASS=button type=button name=btnEdit value=""Add New Application "" title=""Add New Application""onclick=OnAddHmst>"

Below is the Javascript I have. The loading of google.com is a test.
Code:
<script type="text/javascript">
<!--
    function OnAddHmst() {
        var answer = confirm("You are about to add a new application with the same Parcel ID that already exist on the file.  If you click 'OK' the existing application will be marked as inactive and you will be directed to the AssessPro Validation form.  Do you want to continue?")
        if (answer) {
            window.location = "[URL unfurl="true"]http://google.com/";[/URL]
        }
    }
//-->
</script>
Below is the button:
Code:
Response.Write "<input CLASS=button type=button name=btnEdit value=""Add New Application "" title=""Add New Application"" onclick=OnAddHmst()>"

The question I think I have is how do I setup the Javascript to pass parameters to the next page (hmstvalidate.asp)?

Any assistance would be appreciated.

Thanks
 
What parameter do you want to pass? And is the ASP page the page that would be in the window.location (instead of google.com)?
 
Sorry!

There are three parameters that I need to pass. The same ones that are in the vb script.

Yes! The page is hmstvalidate.asp.

The Javascript would essentially duplicate the vb script.

When I execute the vb script it does nothing in IE7 but worked ok in previouse IE releases. As I metioned above I read somewhere that some vb script does not play nice with IE7. It was on this basis that I thought it best to convert to Javascript.

Hope this makes sense.
 
Then I think you just need to do a little tweaking and you are all set. Now I don't know VBSCRIPT, but hopefully this will work... or at least give you some direction.

Code:
<script type="text/javascript">
<!--
function OnAddHmst() {
    var question = "You are about to add a new application with the same Parcel ID that already exist on the file.  If you click 'OK' the existing application will be marked as inactive and you will be directed to the AssessPro Validation form.  Do you want to continue?";

    var answer = confirm(question);

    var strApp = document.getElementById("ApplicationNumber").value;

    var strPID = document.getElementById("pid").value;


    if (answer) {
        var url = "hmstvalidate.asp?";
        url += "AppNumber=" + strApp;
        url += "&parent=edithmst";
        url += "&PID=" + strPID;

        window.location = url;
    }
}
//-->
</script>
 
Thank you MikeyJudd.

I had seen something like this on other web sites but I just didn't know enough about Javascript to know how to put it together.

A star for YOU.

A final question for you or someone else.

Since I'm still trying to learn web applications and have written a few procedures in vb script and not many in Javascript do you or anyone else have a preference as to which language I should concentrate on learning? I'm sure they both have there +'s and -'s.

If you were just starting to learn web programming, which would you prefer?
 
I would definitely use javascript. IE is the only browser that truly supports VBScript (which seems questionable according to your original issue). JavaScript is cross-browser (minus some tweaking you need to do here and there).

Also, there are more and more improvements on JavaScript as well as libraries everywhere.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top