?
Solved

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

Posted on 2008-10-20
10
Medium Priority
?
644 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
[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
  • 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
WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

 
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
 
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 1500 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

764 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