piattnd
asked on
How can I load an html file into a DIV portion of web page
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%20c entral.hta
-------------------------- ---------- ------
I have modified the code and removed any server name for security reasons.
Any help would be great!
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%
--------------------------
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>
<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)">
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.
<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.
and of course you can also load a page into an iframe on mouse over, on change or any other JS action
ASKER
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.
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.
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?
ASKER
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
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>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
ASKER
Thank you again for your help!
ASKER
Darn, was hoping it was that easy!