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>
    <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;
        width: 25%;
        color: #0000CC;
        font-weight: 700;
        width: 213px;
    <script type="text/javascript">
    function OnGenReq()
       var ret = MyOCX.GenerateReq(Text1.value, Text2.value, Text3.value, length1.value, Text4.value);
       myreq.value = MyOCX.ReqString;
       //document.getElementById("myreq").value = MyOCX.ReqString;
       //document.getElementById("myreq").innerHTML = "teststring";
    <p id="demo"></p>
    <object id="MyOCX" width="0" height="0" codebase="C:\Users\Administrator\Documents\Activex.cab"
        <param name="_Version" value="65536">
        <param name="_ExtentX" value="2646">
        <param name="_ExtentY" value="1323">
        <param name="_StockProps" value="0">
    <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>
    <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)
    <label for="myreq">Req String</label><br><textarea id="myreq" rows="15" cols="66"></textarea><br><br>

    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;


    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?


    Thursday, July 19, 2012 5:04 PM