Solved

How can I load an html file into a DIV portion of web page

Posted on 2008-10-20
10
605 Views
Last Modified: 2012-05-05
I've created an HTA application that serves as a front end for some tools I've created for my workplace.  I have a drag down box that has a list of all available tools to run and I want to add the "onchange" feature to load the required input needed to run the script.  I already know how to gather the information from the user in an IE page and pass it to vbscript, I just need to figure out how to load that form into the DIV or iframe.

I've toyed around with javascript and have failed so far to get it to work.  I've attached the code and I'm getting the following script error:

------------------------------------------
Line: 89
Char: 1
Error: Type mismatch: 'ScriptInputSelection'
Code: 0
URL: file:///I:/scripts/Script%20Central/script%20central.hta
------------------------------------------

I have modified the code and removed any server name for security reasons.

Any help would be great!
<head>

<title>Script Central</title>

<HTA:APPLICATION 

     APPLICATIONNAME="Script Central"

     SCROLL="no"

     BORDER="THIN"

     SINGLEINSTANCE="yes"

     WINDOWSTATE="normal"

     MINIMIZEBUTTON="no"

     MAXIMIZEBUTTON="no"

     ICON="\\path\icons\icon.ico"

>

</head>
 

<script language="text\javascript">

	

	Function ScriptInputSelect(SelectScript)

		switch(script){

			case User Account Management: document.all.ScriptInput.src='http://google.com';break;

			case Delete User Account:document.all.ScriptInput.src='http://yahoo.com';break;

				}

	End Function
 

</script>
 

<script language="VBScript">
 

    Sub RunScript

		strScriptSelected = SelectScript.Value

		Set objShell = CreateObject("WScript.Shell")

		

        select case strScriptSelected

			case "User Account Management"

				strVBSFile = "\\path\user account management.vbs"

			case "Delete User Account"

				strVBSFile = "\\path\delete user.vbs"

			case "Disabled Accounts Report"

				strVBSFile = "\\path\disabled accounts.vbs"

			case "Agent Profile Cleanup"

				strVBSFile = "\\path\agent profile cleanup.vbs"

			case "Proxy Check"

				strVBSFile = "\\path\proxy test.vbs"

		End Select

		objShell.Run "wscript.exe " & chr(34) & strVBSFile & chr(34)

    End Sub
 

    Sub ExplainScript

		

		strScriptSelected = SelectScript.Value

		

        select case strScriptSelected

			case "User Account Management"

				strURL = "\\path\user account management.html"

			case "Delete User Account"

				strURL = "\\path\delete user.html"

			case "Disabled Accounts Report"

				strURL = "\\path\Disabled Accounts Report.html"

			case "Agent Profile Cleanup"

				strURL = "\\path\agent profile cleanup.html"

			case "Proxy Check"

				strURL = "\\path\proxy test.html"

		End Select

		

	Set objExplorer = CreateObject("InternetExplorer.Application")

	objExplorer.ToolBar = 0

	objExplorer.StatusBar = 0

	objExplorer.Width = 800

	objExplorer.Height = 600

	objExplorer.Left = 200

	objExplorer.Top = 150

	objExplorer.Visible = 1

	objExplorer.resizable = 1

	objExplorer.Navigate strURL
 

    End Sub

    

</script>
 

<body>

<script type="text/javascript">

	{

	window.resizeTo(400,600)

	window.moveTo(0,0);

	}

		

</script>
 

<div align="center">

<select size="1" width="30" name="SelectScript" onchange="ScriptInputSelection(SelectScript)">

    <option value="User Account Management">User Account Management</option>

    <option value="Delete User Account">Delete User Account</option>

    <option value="Disabled Accounts Report">Disabled Accounts Report</option>

    <option value="Agent Profile Cleanup">Agent Profile Cleanup</option>

    <option value="Proxy Check">Proxy Check</option>

</select> 

</div>

<br>

<div align="center">

<input type="button" value="RunScript" name="run_script" onClick="RunScript">

<input type="button" value="ExplainScript" name="explain_script" onClick="ExplainScript">

<br>

<br>

<iframe name="ScriptInput" width=375 height=200 frameborder=yes></iframe>

</body>

Open in new window

0
Comment
Question by:piattnd
  • 5
  • 4
10 Comments
 
LVL 12

Author Comment

by:piattnd
ID: 22763170
I caught an error in my code at the "onchange" declaration.  I noticed I spelled the function differently than I declared it up top.  I corrected that and removed the quotes, still same issue.

Darn, was hoping it was that easy!
0
 
LVL 82

Expert Comment

by:hielo
ID: 22763222

<script language="text/javascript">

	

	function ScriptInputSelect(val)

		switch(val){

			case 'User Account Management': document.all.ScriptInput.src='http://google.com';break;

			case 'Delete User Account':document.all.ScriptInput.src='http://yahoo.com';break;

				}

	}

 

</script>
 
 

<select size="1" width="30" name="SelectScript" onchange="ScriptInputSelect(this.value)">

Open in new window

0
 
LVL 44

Expert Comment

by:scrathcyboy
ID: 22763804
The iframe is the easiest to load an entire page into --

<IFRAME name=iframe1 width = xxx height = yyy src="startpage.html border=0> </iframe>

<A href="newpage.html" target="iframe1"> load this page </A>

just by specifying the target="iframe1" you can load any html page into the iframe, and they are all indexed fine.
0
 
LVL 44

Expert Comment

by:scrathcyboy
ID: 22763816
and of course you can also load a page into an iframe on mouse over, on change or any other JS action
0
 
LVL 12

Author Comment

by:piattnd
ID: 22769577
Hielo:

I tried that code and I still get a mismatch....

Scrathcyboy,

I am currently using an Iframe, but I need to send the "onchange" to a function.  As you can see in my code, there are several choices and it needs to read what choice is selected and change the information displayed in the Iframe based on what selection they made.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 44

Expert Comment

by:scrathcyboy
ID: 22770381
yes I see all that, and functions are the best anyway.  Is the iframe change not working, or is the problem that you are getting a script error because of HTA coding problems?  This script is IE specific, you know?
0
 
LVL 12

Author Comment

by:piattnd
ID: 22771267
The HTA is simply HTML code that acts as an EXE.  I tried putting the code into an HTML file and got the same results.

I've attached a new snippet of code.... onchange calls a VBScript Sub called "ScriptInput".

The sub has inside of it the following (just as a test).  I get the error "expected statement" on the line where I designate the HREF.  Does this have to be a Javascript function?  If so, how do you do the case/switch to recognize the user's selection and then execute the changing of the iframe content?

Sub ScriptInput
strScriptSelected = SelectScript.Value
select case strScriptSelected
case "User Account Management"
<A href='www.google.com' target='ScriptInput'></A>
End Select
End Sub

<select size="1" width="30" name="SelectScript" onchange="ScriptInput">

    <option value="User Account Management">User Account Management</option>

    <option value="Delete User Account">Delete User Account</option>

    <option value="Disabled Accounts Report">Disabled Accounts Report</option>

    <option value="Agent Profile Cleanup">Agent Profile Cleanup</option>

    <option value="Proxy Check">Proxy Check</option>

</select>

Open in new window

0
 
LVL 44

Accepted Solution

by:
scrathcyboy earned 500 total points
ID: 22771688
If it was just javascript it would be this --

<select size="1" width="30" name="SelectScript" onchange="ScriptInput(this)">

function ScriptInput(sel)  {
var strScriptSelected = sel.options[sel.selectedIndex].value;
....etc ....

If you translate that to VB or whatever, you are getting the correct selected index

and at the link you would not use the <A> tags to jump to the link, but something like -
location.href  = 'www.google.com' target='ScriptInput';

Since your code is using 3 different languages, the source of the error is not instantly apparent.
0
 
LVL 12

Author Comment

by:piattnd
ID: 22771857
Ok, so with the information you provided me, I was able to come up with the following VBscript SUB.  Thank you MUCH for the assistance!
    Sub ScriptInput

    

		strScriptSelected = SelectScript.Value

		

		select case strScriptSelected

			case "User Account Management"

				document.ScriptInput.location.href = "\\path\UAM Input.html"

			case "Delete User Account"

				document.ScriptInput.location.href = "\\path\Delete User input.html"

			case "Disabled Accounts Report"

				document.ScriptInput.location.href = "\\path\Disabled Accounts Report input.html"

			case "Agent Profile Cleanup"

				document.ScriptInput.location.href = "\\path\Agent profile cleanup input.html"

			case "Proxy Check"

				document.ScriptInput.location.href = "\\path\proxy test input.html"

		End Select

	

	End Sub

Open in new window

0
 
LVL 12

Author Closing Comment

by:piattnd
ID: 31508525
Thank you again for your help!
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now