locked
I get "ReferenceError:'myreq' is undefined" error for <textarea> variable? RRS feed

  • Question

  • Hi all;

    I have an ActiveX control that use it's functionality in a html file, so that I call it's methods and properties 

    using a javascript function as below:

    <!DOCTYPE html>
    <html>
    <head>
    <title></title>
    <style type="text/css">
    
    fieldset {
      border-color: #000;
      border-width: 3px;
      border-style: solid;
      padding: 10px;
      margin: 0;
      min-width: 400px;
      max-width: 800px;
      width: 800px; 
    }
    
    fieldset legend {
                color: blue
    	font-size: 1.1em; 
    }
    
    fieldset label:first-letter {
    	text-decoration: underline;   
    }
    
    input, textarea, select {
    	width: auto;
    	margin: 5px 0 0 10px;
    }
    
    .style1
    {
        width: 25%;
    }
    .style2
    {   
        color: #0000CC;
        font-weight: 700;
    }
    .style3
    {
        width: 213px;
    }
    </style>
    
    <script type="text/javascript">
    
    function OnGenReq()
    {
         
       var ret = MyOCX.GenerateReq(Text1.value, Text2.value, Text3.value, length1.value, Text4.value);
       document.getElementById("demo").innerHTML=ret;
    
       myreq.value = MyOCX.ReqString;
       //document.getElementById("myreq").value = MyOCX.ReqString;
       //document.getElementById("myreq").innerHTML = "teststring";
    
    }
    </script>
    </head>
    
    <body>
    <p id="demo"></p>
    <object id="MyOCX" width="0" height="0" codebase="C:\Users\Administrator\Documents\Activex.cab"
     classid="clsid:8F91127E-A84B-4FBD-AB43-AA63A63C0BE5">
        <param name="_Version" value="65536">
        <param name="_ExtentX" value="2646">
        <param name="_ExtentY" value="1323">
        <param name="_StockProps" value="0">
    </object>
    <p></p>
    
    <fieldset>
    <legend class="style2">Generate Request:</legend>
    
    <label for="Text1">First string Arg:</label><input id="Text1" type="text"><br>
    <label for="Text2">Second string Arg:</label><input id="Text2" type="text"><br>
    <label for="Text3">Third string Arg:</label><input id="Text3" type="text"><br>
    <label for="length1">Length value:</label> 
    <select id="length1"> 
      <option selected="selected" value="100">100</option>
      <option value="200">200</option>
      <option value="300">300</option>
    </select><br>
    <label for="Text4">Forth string Arg:</label><input id="Text4" size="30" type="text"><br><br>
    
    <label for="gen"></label><input id="gen" value="Generate Request" type="button" onclick="try{OnGenReq()}catch(e)
    
    {alert(e)}"><br><br>
    <center> 
    <label for="myreq">Req String</label><br><textarea id="myreq" rows="15" cols="66"></textarea><br><br>
    </center>
    </fieldset>
    
    </body>
    </html>

    As you see in the html code, I have a <textarea> tag with "myreq" id that want to display "ReqString" value (that 

    is a custom property of the activex) into textarea.

    When I click "Generate Request" button, "MyOCX.GenerateReq" method runs to assign a string value to "ReqString" 

    property. But when I assign "MyOCX.ReqString" value to "myreq" to be displayed in the textarea using either:
     
    myreq.value = MyOCX.ReqString;

    OR

    document.getElementById("myreq").value = MyOCX.ReqString;

    I get the error "ReferenceError:'myreq' is undefined", while "myreq" is defined within the <fieldset> tag!

    Could you tell me what's wrong with this code?

    TIA.

    Thursday, July 19, 2012 5:04 PM