Hi,
This is partly a reference reminder for me, but as there are few examples on Google, I am adding it here. Hopefully it will help others...
Basically the code below shows how to reference form objects between HTML iFRAMEs for VBScript based HTA's.
Review the attachment for the basic form.
To move the value in value 1 (main window) to value 2 (iframe):
HTML (mainForm.hta)
VBScript (main.vbs)
HTML (iframeForm.htm)
VBScript (main.vbs)
The VBScript code is written in one vbs file that is referenced in both htm files using the following code place in the <head></head> tags:
The HTML code is written in two files, mainForm.htm. This has the IFRAME tag referencing iframeForm.htm:
Hope this helps. I will upload the three complete working files at some point soon.
Woter
This is partly a reference reminder for me, but as there are few examples on Google, I am adding it here. Hopefully it will help others...
Basically the code below shows how to reference form objects between HTML iFRAMEs for VBScript based HTA's.
Review the attachment for the basic form.
To move the value in value 1 (main window) to value 2 (iframe):
HTML (mainForm.hta)
Code:
<input id="val1TXT" name="TXT_VAL1" type="text" value="" />
<input id="test1BTN" type="button" value="Test 1" onClick="test1BTN()" />
VBScript (main.vbs)
Code:
Function test1BTN()
'gets variable from val1TXT
str = window.parent.document.getElementById("val1TXT").value
'sets variable to val2TXT
document.getElementById("IF01").contentWindow.testFromMainWindowTXT.value = str
End Function
HTML (iframeForm.htm)
Code:
<input id="val2TXT" type="text" />
<input id="test2BTN" type="button" value="Test 2" onclick="testBTN2()">
VBScript (main.vbs)
Code:
Function testBTN()
'get variable from val1TXT
str = window.parent.document.getElementById("val1TXT").value
'Output as message box
MsgBox "Hello " & str
End Function
The VBScript code is written in one vbs file that is referenced in both htm files using the following code place in the <head></head> tags:
Code:
<SCRIPT language="VBScript" src="..\bin\main.vbs"></script>
The HTML code is written in two files, mainForm.htm. This has the IFRAME tag referencing iframeForm.htm:
Code:
<iframe ID="IF01" border=1 src="iframeForm.htm"
name = "container"
id = "CONTAINER"
<!-- Application="yes" element allows vbs code to execute in the iframe.-->
application="yes"
style="border-style: none; position:absolute; width:666px; height:399px; left: 5px; top: 164px; margin-top: 0px;">
</iframe>
Hope this helps. I will upload the three complete working files at some point soon.
Woter