Issue With Autofill Input

2 posts by 2 authors in: Forums > CMS Builder
Last Post: October 30, 2019   (RSS)

By nmsinc - October 27, 2019 - edited: October 28, 2019

I'm, having an issue with the following code for a autofill textarea. I know that using a input statement with "textarea" always reverts to "text" in HTML. What changes do I need to make to force the autofill text choice to fill in a "textarea" box rather than a "text" box, also; when using the form in the EDIT mode to have the $request populate within the box?

Another help would be to push the autofill text onto a WYSIWYG editor textarea...

Code as follows:

<div>
    <br>
    Choose Content:
    <br>
    <select id="content" onChange="return setMail()">
    <option value="">Choose A Communication</option>
    <?php foreach ($communicationsRecords as $record): ?>
    <option value = "<?php echo $record['num'];?>"><?php echo $record['title'];?></option>
    </select>
    <?php endforeach ?>
</div>
<br>
<div>       
    Content:
    <br>
    <input type='textarea' name='content' rows='5' cols='50' id='requestedContent' class='form-control'><?php echo @$_REQUEST['content'] ?>
</div>

<script>
function setMail(){
    // find the dropdown
    var ddl = document.getElementById("content");
    // find the selected option
    var selectedOption = ddl.options[ddl.selectedIndex];
    // find the attribute value
    var mailValue = selectedOption.getAttribute("value");
    // find the textbox
    var textBox = document.getElementById("requestedContent");

    // set the textbox value
    if(mailValue=="1"){
        textBox.value = "<?php echo $record['content'];?>";
    }
}
</script>

nmsinc