[thelist] FW: HTC question
Mckinney, Lori K
lkmckinn at ingr.com
Wed Dec 19 10:39:06 CST 2001
My apologies to those of you on the Internet Explorer HTML and scripting
list as this will be the second time you have seen this post but I didn't
get an answer so I am trying Evolt.
Hi. I hope this is a simple thing that I am just missing. It involves an
HTC this is not a viewLink and that contains a SELECT.
I found an example on MSDN and whittled it down to as small a test case as I
could. The example works fine when the htc is a ViewLink and the onchange
event of the select fires as expected. If I change the htc to not be a
viewLink, the event does not fire. If I change the modified code to put the
onchange event on the SELECT element itself, I get an error.
Here is the code of the main page:
<HTML XMLNS:FormsTools>
<head>
<title>Other Select Box Sample</title>
<?IMPORT namespace="FormsTools" implementation="formSubclass.htc"/>
<?IMPORT namespace="FormsTools" implementation="formSubclass2.htc"/>
</head>
<body>
If you select a different value in this select, you should get an alert
message saying "hi"<P>
<FormsTools:InputSubclass1 Name="Input1" /><P><P>
If you select a different value in this select, you should get an alert
message saying "hello"<P>
<FormsTools:InputSubclass2 Name="Input2" />
</body>
</html>
Here is the (modified but working) original htc code (formSubclass.htc):
<PUBLIC:Component TagName="InputSubclass1">
<PUBLIC:DEFAULTS viewLinkContent tabStop/>
<PUBLIC:ATTACH event="ondocumentready" onevent="Load();"/>
<SCRIPT>
function Load() { ; }
function sel1_onchange() { alert ("hi"); }
</SCRIPT>
<body>
<SELECT name="sel1" onchange="sel1_onchange();">
<option value="0">TV Advertisement
<option value="1">Magazine Advertisement
<option value="2">Word of Mouth
<option value="3">Other
</SELECT>
</body>
</PUBLIC:COMPONENT>
Here is the (modified from viewlink and not working) htc code
(formSubclass2.htc):
<PUBLIC:Component TagName="InputSubclass2">
<PUBLIC:ATTACH event="ondocumentready" onevent="Load();" />
<PUBLIC:ATTACH event="onchange" onevent="sel1_onchange();" />
<!--PUBLIC:METHOD name="sel1_onchange" / -->
<SCRIPT>
function Load() {
// element.innerHTML = "<SELECT name=\"sel1\"
onchange=\"sel1_onchange();\">"+
element.innerHTML = "<SELECT name=\"sel1\">"+
"<option value=\"0\">TV Advertisement<option
value=\"1\">Magazine Advertisement"+
"<option value=\"2\">Word of Mouth<option
value=\"3\">Other</SELECT>";
}
function sel1_onchange() { alert ("hi"); }
</SCRIPT>
</PUBLIC:COMPONENT>
I have tried putting the onchange directly on the SELECT element (with and
without the onchange event in the PUBLIC:ATTACH declaration) and making
sel1_onchange a method (with and without having it as an event as well).
The error I get is Line 0: Object expected. Just FYI, I've tried other
events (declaring them using the PUBLIC:ATTACH), some of which have fired
the function (click and mousing) and others which have not (blur and focus).
What am I missing or have I done wrong? Thanks for any guidance you can
provide.
Lori
More information about the thelist
mailing list