Forum Discussion

cbschne's avatar
cbschne
Ideator I
9 years ago

Script tags in form HTML fields

I am trying to generate HTML dynamically in a form's field that is of type HTML, using code in the form's onLoad event. I am not having any success. Does anyone here know how to do this successfully?  The code generates buttons with onclick attributes that call a function. example: fileid is a variable tagText is variable var Html = '<body><fieldset style="width:175px;background-color:#00000"><legend><b>Help</b></legend><br>'; Html += '<button class="help_me" onclick="downloadFile(' + fileid + ')" >' + tagText + '<br>'; Html += '</fieldset></body>'; Html += '<script>'; Html += 'function downloadFile(fileId) {var inn = parent.thisItem.getInnovator(); var thisFile = inn.getItemById("File",fileId); top.aras.downloadFile(thisFile.node); return false; }'; Html += '</script>'; getFieldByName("htmInstructions").innerHTML = Html;        

1 Reply

  • eli_donahue's avatar
    eli_donahue
    Community Manager
    Try something like this. Instead of adding your function to the html string, you can define the function right in your onLoad event method and still reference it in your button's onclick attribute. // define html contents var Html = '<fieldset style="width:175px;background-color:#00000"><legend><b>Help</b></legend><br>'; Html += '<button class="help_me" onclick="downloadFile(&quot;' + fileid + '&quot;)" >' + tagText + '<br>'; Html += '</fieldset>'; // get field and set contents getFieldByName("htmInstructions").innerHTML = Html; // define function used by button onclick downloadFile = function (fileId) { var inn = parent.thisItem.getInnovator(); var thisFile = inn.getItemById("File", fileId); top.aras.downloadFile(thisFile.node); return false; };
    Eli Donahue Aras Labs Software Engineer