【问题标题】:How do I get a value and id from a textarea that uses a database row as id如何从使用数据库行作为 id 的 textarea 中获取值和 id
【发布时间】:2013-09-24 11:04:26
【问题描述】:

这就是我想要得到的response14.php?questionID=1&question=yes&approved=1

这是我目前收到的response14.php?questionID=[object%20Object]&question=undefined&approved=1

这是js文件:

$(document).ready(function(){
    $(".save_btn").on('click', function() {
         var check = $("input[name=no]").is(":checked")?2:1;
         var questionID = $("textarea[id=questionID]").val();
         var question = $("textarea[value=question]").val();
        location = "response14.php?questionID=" +questionID + "&question=" +question + "&approved=" +check;

这是渲染的 html:

 <td style='border:1px white; padding: 5; margin: 5;'><div id='wrap'>
<textarea cols='85' rows='2' id='3792' class='response textbox'>Hello C!!

Where can I send you fan mail? :)
I want your autograph and I'm from the Philippines :)

God bless Cooper!</textarea>
    YES: <input type='checkbox' name='yes' value='yes'> &nbsp;&nbsp;&nbsp;
    NO: <input type='checkbox' name='no' value='no'>    </div></td></tr><tr style='border:1px white; background-color:lightgrey; color:black; padding: 5; margin: 5;'><td style='border:1px white; vertical-align:top; padding: 5; margin: 5;'>Gavin Casalegno</td>
                      <td style='border:1px white; padding: 5; margin: 5;'><div id='wrap'>
<textarea cols='85' rows='2' id='3793' class='response textbox'>What is your religion?
Do you believe in God?
How much you measure height?</textarea>
    YES: <input type='checkbox' name='yes' value='yes'> &nbsp;&nbsp;&nbsp;
    NO: <input type='checkbox' name='no' value='no'>    </div></td></tr></tbody></table><button type='button' class='save_btn' style='align:right'>Save All</button><br>

关于如何解决这个问题的任何想法???

【问题讨论】:

  • html是如何渲染的?
  • id 试试var questionID = $("textarea").attr('id').val(); 值试试var question = $("textarea").val();

标签: javascript html pdo get textarea


【解决方案1】:

尝试替换

var questionID = $("textarea[id=questionID]").val();
var question = $("textarea[value=question]").val();

与

var questionID = $(textarea).attr('id');
var question = $(textarea).val();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-12-03
    • 1970-01-01
    • 1970-01-01
    • 2016-03-11
    • 2017-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多