如何在<div>类元素中提交文本输入(wysiwyg编辑器)

时间:2015-10-01 17:55:21

标签: javascript jquery html forms wysiwyg

正在使用summernote (wysiwyg) text editor。在以前的编辑器中,可以使用<textarea>提交值。当前编辑器仅使用<div>元素,如果我将<div>类替换为<textarea>,编辑器将停止工作。 summernote代码是

我的textarea是<textarea name='candidate_description'></textarea>

我的表单由JavaScript函数提交

    <form class="form-inline" role="form" action="#" method="post" accept-  charset="utf-8" id="electroal" enctype="multipart/form-data">

    <script>
    function submitForm(action){
    document.getElementById('electroal').action = action;
    document.getElementById('electroal').submit();
    }
    </script>

            <a href="javascript:history.go(0)" class="btn btn-default"> <i class="fa fa-refresh"></i> <b>Refresh</b></a>
            <button type="submit" onclick="submitForm('<?php echo $link[0]; ?>')"></i>Save</button>
            <button type="submit" onclick="submitForm('<?php echo $link[1]; ?>')"></i>Cancel</button>

<div class="form-group input-xxx-x-wider">
    <h6><strong>Description (500 max) <i class="glyphicon glyphicon-star red" ></i></strong></h6>
        <div class="widget-main no-padding">
            <div id="summernote"></div>
        </div>
    <textarea name="candidate_description"></textarea>
</div>
<div class="form-group input-x-wider">
    <h6><strong>Status <i class="glyphicon glyphicon-star red" ></i></strong>| <i>Enable to use or Disable to use later </i></h6>
    <label>
        <input name="candidate_status" value="9" type="radio" checked="checked" class="colored-success">
        <span class="text"> Enabled</span>
    </label>
    <label>
        <input name="candidate_status" value="10" type="radio" class="colored-danger">
        <span class="text"> Disabled</span>
    </label>

</div>

</form>

我对Jquery一无所知,但我可以尝试赶上,请帮助我。

- &gt;我的主要目标是提交包含<div id="summernote">some edited text here</div>元素内编辑文本的表单

我使用function submitForm(action)提交表单,因为onclick="submitForm('<?php echo $link[0]; ?>')"上的链接是动态的,并根据谁登录进行更改。

在网络浏览器上,它看起来像

    <form class="form-inline" role="form" action="#" method="post" accept-charset="utf-8" id="electroal" enctype="multipart/form-data">
    <script>
    function submitForm(action){
    document.getElementById('electroal').action = action;
    document.getElementById('electroal').submit();
    }
    </script>

    <button type="submit" onclick="submitForm('http://localhost/ANU_ELECTRAL1/candidate/save')">Save</button>
    <button type="submit" onclick="submitForm('http://localhost/ANU_ELECTRAL1/candidate')">Cancel</button>

<div class="form-group input-xxx-x-wider">
    <h6><strong>Description (500 max) <i class="glyphicon glyphicon-star red" ></i></strong></h6>
        <div class="widget-main no-padding">
            <div id="summernote"></div>
        </div>
    <textarea name="candidate_description"></textarea>
</div>
<div class="form-group input-x-wider">
    <h6><strong>Status <i class="glyphicon glyphicon-star red" ></i></strong>| <i>Enable to use or Disable to use later </i></h6>
    <label>
        <input name="candidate_status" value="9" type="radio" checked="checked" class="colored-success">
        <span class="text"> Enabled</span>
    </label>
    <label>
        <input name="candidate_status" value="10" type="radio" class="colored-danger">
        <span class="text"> Disabled</span>
    </label>

</div>

</form>

0 个答案:

没有答案