按钮调用键入不匹配

时间:2015-03-13 07:08:14

标签: html vba

我的主要目标是从XML获取值。我已经使用VB代码获得了它。并且必须在HTML页面的下拉列表中填充这些值。

<input id= "BtnNameLoad" type="button" value="Load Name" onclick="BtnNameLoad_onclick()"/>

它说BtnNameLoad_onclick()类型不匹配,我在IE 8上使用它。从我工作的地方,这是唯一可用的浏览器。

HTML code:

<html>
<head>
<title>eGAM Template Migration</title>
<link href="./eGAMMacrosSet.css" rel="stylesheet" type="text/css" />
<script src="../Automation/eGAMServices.bas" type="text/vbscript"></script>
<script type = "text/javascript">
function BtnNameLoad_onclick()
{
    //Get the control ID from dropdown
    var listID = document.getElementById("ddlNames");
    //Check if the object is not null
    if (listID != null)
    {
        for (var i = 0; i < InstNameArray.Length ; i++)
        {
            //Create Element object of type option
            var opt = document.createElement("option");
            //Add the option element to the select item
            listID.options.add(opt);
            //Reading elements from array
            opt.text = InstNameArray[i];
        }
    }
    <!-- Return; -->
}
</script>

</head>
<body>
<center><img src="./banner.jpg" />
<BR/><H1>eGAM Template Data</H1>


<form src="Attributes" action="javascript:void(0);" >

<table border="none" >
<TR><TH width='600'>Search</TH></TR>

<BR/><BR/>
<TR><TD>
Template name:
<select>
  <option value="CFCB">Cargo Floor Cross Beam</option>
  <option value="CFS">Cargo Floor Strut</option>
</select> 
<BR/><BR/>
Sections : 
<select>
  <option value="CFCBSection">Cargo Floor Cross Beam Section 1</option>
  <option value="CFCBSection">Cargo Floor Cross Beam Section 2</option>
</select> 
<BR/><BR/>
<input type='submit' value='Update' onclick='StartScript(me)' />
</td></TR>
</table>

<BR/><BR/>

Instance Names:

<select id="ddlNames" name="D1">
</select><input id= "BtnNameLoad" type="button" value="Load Name" onclick="BtnNameLoad_onclick()"/>


</td></TR>
</table>
</form>

</center>
</body>
</html>

和VB代码:

Sub StartScript(button)

objXMLPath= "..\CFCB.xml"   
Dim xmlDoc
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.Async = False
xmlDoc.Load (objXMLPath)
Set Root = xmlDoc.documentElement
Set NodeList = Root.getElementsByTagName("Instance")
Dim InstName()

i = 0
For Each Elem In NodeList
    Set xmlAttr = Elem.getElementsByTagName(InstrField)(0)
    If i = 0 Then
        ReDim Preserve InstName(i)
        InstName(i) = xmlAttr.Text
        i = i + 1
    ElseIf xmlAttr.Text <> InstName(i - 1) Then
        ReDim Preserve InstName(i)
        InstName(i) = xmlAttr.Text
        i = i + 1
    End If
Next

For p = 0 to InstName.Count - 1
    Page.ClientScript.RegisterArrayDeclaration "InstNameArray", InstName(p)
Next

Dim strScript
strScript = "BtnNameLoad_onclick();"
ClientScript.RegisterStartupScript GetType(Page),"newTest",strScript.ToString, True

End Sub

0 个答案:

没有答案