为表单设置输出onclick

时间:2015-06-22 12:57:05

标签: javascript php html web

我写了这个

<form method="post" id="create">
  <div class="panel panel-success">
    <div class="panel-heading">
      <p>Create a new Wall Post</p>
    </div>
    <div class="panel-body">
      <textarea cols="80" id="text" name="text" rows="10" style="visibility: hidden; display: none;"></textarea>

      <script>
        $('#text').wysibb(options);
      </script>

      <div class="pull-right">
        <br>
        <button onclick="$('#text').val($('#text').htmlcode())" type="submit" name="create" class="btn btn-success">Post</button>
        <button type="reset" name="reset" class="btn btn-danger">Reset</button>
      </div>
    </div>
  </div>
</form>


  <?php
  if (isset($_REQUEST['create'])) {
      $p = WallPostManager::createWallPost($user, UserManager::isLoggedIn(), $_POST['text']);

      if ($p != false) {
          Utils::alert("News Post created", false);
          header('refresh: 1');
      }
  }

但是出于某种原因,当我指定它在.htmlcode()时,我在bbcode中获取'text',可能会发生什么?我做错了什么?

1 个答案:

答案 0 :(得分:0)

$('#text').htmlcode()

不起作用,因为那不是jQuery函数,正如@nthall所提到的那样。尝试将其更改为

$('#text').html()