0

I do have a table which contain some data in it and a form besides it.I am binding this form on click of any row of the table means the data related to the respective row gets filled to the form which are coming from the database,my concern is that out of this data from the database one of the field is "def_text" which is basically stored in the HTML format but i want to show it in plain text format in the form where i am binding it.

<form class="form report live " data-table="contractlistTable" id="contractlistForm"  data-bind="foreach:items"  target="_blank" method="post">
            <input type="hidden" name="pid" id="pid" />
            <div class="control-group ">
                <label class="control-label">Title</label>
                <div class="controls">
                        <input type="text" id="title" name="title" required title="required" placeholder="title" data-bind="value:title" />
                        <input type="checkbox" id="active" name="active" class="check" data-bind="checked: active=='true'"  />Active
                </div>
            </div>
            <div class="control-group ">
                <label class="control-label">Default Text</label>
                <textarea id="def_text" name="def_text" class="htmleditor" rows="9" cols="50" style="width: 600px; height: 190px;" data-bind="value:def_text"> </textarea>
            </div>
</form>

this is the form and the code for the table is

<table class="table table-hover table-bordered" id="contractlistTable" style="width: 304px;">
            <thead>
                <tr>
                    <th>Title</th>
                    <th>Active</th>
                </tr>
            </thead>
            <tbody data-bind="foreach:items" class="bindable" data-model="companycontract">
                 <tr data-bind="attr:{'data-value': id,'data-index':$index}">
                    <td data-bind="text:title"></td>
                    <td>
                        <!-- ko if:active === 'true' -->
                        <span class="badge badge-success"></span>
                        <!-- /ko -->
                        <!-- ko if: active === 'false' -->
                        <span class="badge"></span>
                        <!-- /ko -->
                    </td>
                </tr>
            </tbody>
        </table>

and for binding it i am using Knockout.js

$(function () {
        var myForm = "";
        var formFields;
        $("#contractlistTable tbody tr").live('click', function () {
            var data = [model.companycontract[$(this).attr("data-index")]];
            if (!!formFields) formFields.refill(data);
            else {
                formFields = new DynamicModel(data);
                ko.applyBindings(formFields, document.getElementById("contractlistForm"));
            };

            var id = [$(this).attr("data-value")];

            var kunnr = $('#kunnr').val();
            $('.report').attr("action", 'http://wcidevapps.com/salescentral/pcontract.php?ct=i&knr=' + kunnr + '&cid=' + id);

        });
 });

so please help me on this..

2 Answers 2

2

On your php code you can use strip tags to clear html tags.... Check this: http://php.net/manual/en/function.strip-tags.php

Use like:

$test = '<p>Test</p>, <h1> Big test </h1>';
echo strip_tags($test);

Result: Test, Big test

Sign up to request clarification or add additional context in comments.

Comments

0

if you need to convert your HTML format into Plain Text format use HTML Editor.

var wysihtml5Editor222 = $('#iiii').wysihtml5().data("wysihtml5").editor;

and in the view:

 <textarea id="iiii" name="iiii" class="htmleditor" rows="9" cols="50" style="width: 600px; height: 190px;""></textarea>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.